improve bundle configuration and registration.
This commit is contained in:
parent
300ab50a84
commit
70082508f5
|
@ -35,6 +35,7 @@
|
|||
|
||||
Router::register(array('GET /', 'GET /home'), function()
|
||||
{
|
||||
var_dump(Bundle::$bundles);
|
||||
return View::make('home.index');
|
||||
});
|
||||
|
||||
|
|
|
@ -27,6 +27,10 @@
|
|||
| Now the bundle will be recognized by Laravel and will be able
|
||||
| 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();
|
|
@ -35,14 +35,22 @@ public static function register($bundle, $config = array())
|
|||
{
|
||||
$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']))
|
||||
{
|
||||
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
|
||||
// have to worry about the developer adding or not adding it to the location
|
||||
// path for the bundle. This makes sure it is always there.
|
||||
// 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'] = BUNDLE_PATH.rtrim($config['location'], DS).DS;
|
||||
|
||||
static::$bundles[$bundle] = array_merge($defaults, $config);
|
||||
|
|
|
@ -47,7 +47,9 @@
|
|||
*/
|
||||
$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);
|
||||
}
|
Loading…
Reference in New Issue