Commit 70082508 authored by Taylor Otwell's avatar Taylor Otwell

improve bundle configuration and registration.

parent 300ab50a
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
Router::register(array('GET /', 'GET /home'), function() Router::register(array('GET /', 'GET /home'), function()
{ {
var_dump(Bundle::$bundles);
return View::make('home.index'); return View::make('home.index');
}); });
......
...@@ -27,6 +27,10 @@ ...@@ -27,6 +27,10 @@
| Now the bundle will be recognized by Laravel and will be able | Now the bundle will be recognized by Laravel and will be able
| to respond to requests beginning with "admin"! | to respond to requests beginning with "admin"!
| |
| Have a bundle that lives in the root of the bundle directory
| and doesn't respond to any requests? Just add the bundle
| name to the array and we'll take care of the rest.
|
*/ */
return array(); return array();
\ No newline at end of file
...@@ -35,14 +35,22 @@ class Bundle { ...@@ -35,14 +35,22 @@ class Bundle {
{ {
$defaults = array('handles' => null, 'auto' => false); $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'])) if ( ! isset($config['location']))
{ {
throw new \Exception("Location not set for bundle [$bundle]"); throw new \Exception("Location not set for bundle [$bundle]");
} }
// We will trim the trailing slash from the location and add it back so we don't // We will trim the trailing slash from the location and add it back so
// have to worry about the developer adding or not adding it to the location // we don't have to worry about the developer adding or not adding it
// path for the bundle. This makes sure it is always there. // to the location path for the bundle.
$config['location'] = BUNDLE_PATH.rtrim($config['location'], DS).DS; $config['location'] = BUNDLE_PATH.rtrim($config['location'], DS).DS;
static::$bundles[$bundle] = array_merge($defaults, $config); static::$bundles[$bundle] = array_merge($defaults, $config);
......
...@@ -47,7 +47,9 @@ Autoloader::$aliases = Config::get('application.aliases'); ...@@ -47,7 +47,9 @@ Autoloader::$aliases = Config::get('application.aliases');
*/ */
$bundles = require BUNDLE_PATH.'bundles'.EXT; $bundles = require BUNDLE_PATH.'bundles'.EXT;
foreach ($bundles as $bundle => $config) foreach ($bundles as $bundle => $value)
{ {
Bundle::register($bundle, $config); if (is_numeric($bundle)) $bundle = $value;
Bundle::register($bundle, $value);
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment