From 02483aca83749ee9fea5b7b635798501e28ce04b Mon Sep 17 00:00:00 2001 From: Falk Doering Date: Mon, 12 Aug 2013 16:45:35 +0200 Subject: [PATCH] Add doctrine dbal adapter factory --- .../Factory/DoctrineDbalAdapterFactory.php | 71 +++++++++++++++++++ Resources/config/adapter_factories.xml | 4 +- Resources/config/gaufrette.xml | 2 +- 3 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 DependencyInjection/Factory/DoctrineDbalAdapterFactory.php diff --git a/DependencyInjection/Factory/DoctrineDbalAdapterFactory.php b/DependencyInjection/Factory/DoctrineDbalAdapterFactory.php new file mode 100644 index 0000000..4182ca2 --- /dev/null +++ b/DependencyInjection/Factory/DoctrineDbalAdapterFactory.php @@ -0,0 +1,71 @@ +setDefinition($id, new DefinitionDecorator('knp_gaufrette.adapter.doctrine_dbal')) + ->addArgument(new Reference($config['doctrine_dbal_id'])) + ->addArgument($config['table']); + + if (isset($config['columns'])) { + $definition->addArgument($config['columns']); + } + } + + /** + * Returns the key for the factory configuration + * + * @return string + */ + function getKey() + { + return 'doctrine_dbal'; + } + + /** + * Adds configuration nodes for the factory + * + * @param NodeDefinition $builder + */ + function addConfiguration(NodeDefinition $builder) + { + $builder + ->children() + ->scalarNode('doctrine_dbal_id')->isRequired()->cannotBeEmpty()->end() + ->scalarNode('table')->isRequired()->cannotBeEmpty()->end() + ->arrayNode('columns') + ->children() + ->scalarNode('key')->end() + ->scalarNode('content')->end() + ->scalarNode('mtime')->end() + ->scalarNode('checksum')->end() + ->end() + ->end() + ->end() + ; + } +} diff --git a/Resources/config/adapter_factories.xml b/Resources/config/adapter_factories.xml index b316e47..7ca0153 100644 --- a/Resources/config/adapter_factories.xml +++ b/Resources/config/adapter_factories.xml @@ -23,6 +23,9 @@ + + + @@ -48,4 +51,3 @@ - diff --git a/Resources/config/gaufrette.xml b/Resources/config/gaufrette.xml index 36ec7d5..422a8bf 100644 --- a/Resources/config/gaufrette.xml +++ b/Resources/config/gaufrette.xml @@ -23,6 +23,7 @@ + @@ -48,4 +49,3 @@ -