added ability to specify autoloader configuration for bundles in bundles.php
This commit is contained in:
parent
a88511428a
commit
ec84d3f90d
|
@ -63,6 +63,8 @@ public static function register($bundle, $config = array())
|
|||
}
|
||||
|
||||
static::$bundles[$bundle] = array_merge($defaults, $config);
|
||||
|
||||
static::autoloading($bundle, $config);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -125,6 +127,35 @@ public static function routes($bundle)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the auto-loading configuration for a bundle.
|
||||
*
|
||||
* @param string $bundle
|
||||
* @param array $config
|
||||
* @return void
|
||||
*/
|
||||
protected static function autoloading($bundle, $config)
|
||||
{
|
||||
$path = trim(Bundle::path($bundle), DS);
|
||||
|
||||
foreach ((array) $config['autoloads'] as $type => $mappings)
|
||||
{
|
||||
// When registering each type of mapping we'll replace the (:bundle)
|
||||
// place-holder with the path to the bundle's root directory, so
|
||||
// the developer may dryly register the mappings.
|
||||
$mappings = array_map(function($mapping) use ($path)
|
||||
{
|
||||
return str_replace('(:bundle)', $path, $mapping);
|
||||
|
||||
}, $mappings);
|
||||
|
||||
// Once the mappings are formatted, we will call the Autoloader
|
||||
// function matching the mapping type and pass in the array of
|
||||
// mappings so they can be registered and used.
|
||||
Autoloader::$type($mappings);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable a bundle for the current request.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue