diff --git a/application/config/application.php b/application/config/application.php index 568dc7b5..d95e86ad 100644 --- a/application/config/application.php +++ b/application/config/application.php @@ -21,7 +21,6 @@ |-------------------------------------------------------------------------- | | If you are including the "index.php" in your URLs, you can ignore this. - | | However, if you are using mod_rewrite to get cleaner URLs, just set | this option to an empty string and we'll take care of the rest. | @@ -73,13 +72,13 @@ | SSL Link Generation |-------------------------------------------------------------------------- | - | Many sites use SSL to protect their users data. However, you may not - | always be able to use SSL on your development machine, meaning all HTTPS - | will be broken during development. + | Many sites use SSL to protect their users data. However, you may not be + | able to use SSL on your development machine, meaning all HTTPS will be + | broken during development. | | For this reason, you may wish to disable the generation of HTTPS links - | throughout your application. This option does just that. All attempts to - | generate HTTPS links will generate regular HTTP links instead. + | throughout your application. This option does just that. All attempts + | to generate HTTPS links will generate regular HTTP links instead. | */ @@ -90,7 +89,7 @@ | Application Timezone |-------------------------------------------------------------------------- | - | The default timezone of your application. This timezone will be used when + | The default timezone of your application. The timezone will be used when | Laravel needs a date, such as when writing to a log file or travelling | to a distant star at warp speed. | @@ -98,20 +97,41 @@ 'timezone' => 'UTC', + /* + |-------------------------------------------------------------------------- + | Bundle Options + |-------------------------------------------------------------------------- + | + | Here you may specify options related to application bundles, such as the + | amount of time the bundle manifest is cached. Each option is detailed + | below with suggestions for sensible values. + | + | Cache: + | + | All bundles have a "bundle.info" file which contains information such + | as the name of a bundle and the URIs it responds to. This value is + | the number of that bundle info is cached. + | + */ + + 'bundle' => array( + + 'cache' => 0, + + ), + /* |-------------------------------------------------------------------------- | Class Aliases |-------------------------------------------------------------------------- | | Here, you can specify any class aliases that you would like registered - | when Laravel loads. Aliases are lazy-loaded, so add as many as you want. + | when Laravel loads. Aliases are lazy-loaded, so feel free to add! | | Aliases make it more convenient to use namespaced classes. Instead of | referring to the class using its full namespace, you may simply use | the alias defined here. | - | We have already aliased common Laravel classes to make life easier. - | */ 'aliases' => array( diff --git a/laravel/bundle.php b/laravel/bundle.php index e8d2b094..1d79f2ba 100644 --- a/laravel/bundle.php +++ b/laravel/bundle.php @@ -1,5 +1,7 @@ isDir()) + { + $path = $item->getRealPath().DS.'bundle.info'; + + // If we found a file, we'll require in the array it contains + // and add it to the directory. The info array will contain + // basic info like the bundle name and any URIs it may + // handle incoming requests for. + if (file_exists($path)) + { + $info = require $path; + + $info['location'] = dirname($path).DS; + + $bundles[$info['name']] = $info; + + continue; + } + // If a bundle.info file doesn't exist within a directory, + // we'll recurse into the directory to keep searching in + // the bundle directory for nested bundles. + else + { + $recurse = static::detect($item->getRealPath()); + + $bundles = array_merge($bundles, $recurse); + } + } + } + + return $bundles; + } + /** * Register a bundle for the application. * - * @param string $bundle - * @param mixed $config + * @param array $config * @return void */ - public static function register($bundle, $config = array()) + public static function register($config) { $defaults = array('handles' => null, 'auto' => false); - // If the given config is actually a string, we will assume it is a location - // and convert it to an array so that the developer may conveniently add - // bundles to the configuration without making an array for each one. - if (is_string($config)) - { - $config = array('location' => $config); - } - - if ( ! isset($config['location'])) - { - $config['location'] = $bundle; - } - - // We will trim the trailing slash from the location and add it back so - // we don't have to worry about the developer adding or not adding it - // to the location path for the bundle. - $config['location'] = path('bundle').rtrim($config['location'], DS).DS; - - // If the handles clause is set, we will append a trailing slash so - // that it is not ultra-greedy. Otherwise, bundles that handle "s" - // would handle all bundles that start with "s". + // If a handles clause has been specified, we will cap it with a trailing + // slash so the bundle is not extra greedy with its routes. Otherwise a + // bundle that handles "s" would handle all routes beginning with "s". if (isset($config['handles'])) { - $config['handles'] = $config['handles'].'/'; + $config['handles'] = str_finish($config['handles'], '/'); } - static::$bundles[$bundle] = array_merge($defaults, $config); + static::$bundles[$config['name']] = array_merge($defaults, $config); } /** @@ -82,7 +115,7 @@ public static function start($bundle) { if (static::started($bundle)) return; - if ($bundle !== DEFAULT_BUNDLE and ! static::exists($bundle)) + if ( ! static::exists($bundle)) { throw new \Exception("Bundle [$bundle] has not been installed."); } diff --git a/laravel/core.php b/laravel/core.php index 7da6242e..756da506 100644 --- a/laravel/core.php +++ b/laravel/core.php @@ -53,7 +53,7 @@ */ $bundles = Cache::remember('laravel.bundle.manifest', function() { - return Bundle::detect(); + return Bundle::detect(path('bundle')); }, Config::get('application.bundle.cache')); diff --git a/laravel/helpers.php b/laravel/helpers.php index 028d8a82..6af310da 100644 --- a/laravel/helpers.php +++ b/laravel/helpers.php @@ -351,6 +351,18 @@ function str_contains($haystack, $needle) return strpos($haystack, $needle) !== false; } +/** + * Cap a string with a single instance of the given string. + * + * @param string $value + * @param string $cap + * @return string + */ +function str_finish($value, $cap) +{ + return rtrim($value, $cap).$cap; +} + /** * Return the value of the given item. * diff --git a/storage/cache/.gitignore b/storage/cache/.gitignore index e69de29b..8ba4aece 100644 --- a/storage/cache/.gitignore +++ b/storage/cache/.gitignore @@ -0,0 +1 @@ +laravel.bundle.manifest \ No newline at end of file