Commit ec84d3f9 authored by Taylor Otwell's avatar Taylor Otwell

added ability to specify autoloader configuration for bundles in bundles.php

parent a8851142
......@@ -63,6 +63,8 @@ class Bundle {
}
static::$bundles[$bundle] = array_merge($defaults, $config);
static::autoloading($bundle, $config);
}
/**
......@@ -125,6 +127,35 @@ class 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.
*
......
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