private function setupLocator(IndexedServiceContainer $container)
{
$container->define('locator.resource_manager', function (IndexedServiceContainer $c) {
$manager = new Locator\PrioritizedResourceManager();
array_map(array($manager, 'registerLocator'), $c->getByTag('locator.locators'));
return $manager;
});
$container->addConfigurator(function (IndexedServiceContainer $c) {
$suites = $c->getParam('suites', array('main' => ''));
foreach ($suites as $name => $suite) {
$suite = is_array($suite) ? $suite : array('namespace' => $suite);
$defaults = array('namespace' => '', 'spec_prefix' => 'spec', 'src_path' => 'src', 'spec_path' => '.', 'psr4_prefix' => null);
$config = array_merge($defaults, $suite);
if (!is_dir($config['src_path'])) {
mkdir($config['src_path'], 0777, true);
}
if (!is_dir($config['spec_path'])) {
mkdir($config['spec_path'], 0777, true);
}
$c->define(sprintf('locator.locators.%s_suite', $name), function (IndexedServiceContainer $c) use($config) {
return new Locator\PSR0\PSR0Locator($c->get('util.filesystem'), $config['namespace'], $config['spec_prefix'], $config['src_path'], $config['spec_path'], $config['psr4_prefix']);
}, ['locator.locators']);
}
});
}