Boot filesystems for a specified domain

This commit is contained in:
bertillon clement
2012-10-10 17:32:37 +02:00
parent 790652531f
commit 237055ef01
8 changed files with 252 additions and 0 deletions

View File

@@ -52,6 +52,11 @@ class KnpGaufretteExtension extends Extension
$container->getDefinition('knp_gaufrette.filesystem_map')
->replaceArgument(0, $map);
if (isset($config['stream_wrapper'])) {
$container->setParameter('knp_gaufrette.stream_wrapper.protocol', $config['stream_wrapper']['protocol']);
$container->setParameter('knp_gaufrette.stream_wrapper.filesystems', $config['stream_wrapper']['filesystems']);
}
}
private function createAdapter($name, array $config, ContainerBuilder $container, array $factories)

View File

@@ -37,6 +37,7 @@ class MainConfiguration implements ConfigurationInterface
$this->addAdaptersSection($rootNode, $this->factories);
$this->addFilesystemsSection($rootNode);
$this->addStreamWrapperSection($rootNode);
$rootNode
// add a faux-entry for factories, so that no validation error is thrown
@@ -84,4 +85,30 @@ class MainConfiguration implements ConfigurationInterface
->end()
;
}
private function addStreamWrapperSection(ArrayNodeDefinition $node)
{
$node
->children()
->arrayNode('stream_wrapper')
->children()
->scalarNode('protocol')->defaultValue('gaufrette')->end()
->arrayNode('filesystems')
->beforeNormalization()
->ifTrue(function ($array) {
return !(bool)count(array_filter(array_keys($array), 'is_string'));
})
->then(function ($array) {
return array_combine($array, $array);
})
->end()
->useAttributeAsKey('key')
->prototype('scalar')
->end()
->end()
->end()
->end()
->end()
;
}
}