From d547add0788f3bee489c54a8c2642a90343e4cc2 Mon Sep 17 00:00:00 2001 From: Robin van der Vleuten Date: Thu, 1 Mar 2012 17:13:11 +0100 Subject: [PATCH] CacheAdapterFactory created --- .../Factory/CacheAdapterFactory.php | 51 +++++++++++++++++++ Resources/config/adapter_factories.xml | 3 ++ Resources/config/gaufrette.xml | 1 + 3 files changed, 55 insertions(+) create mode 100644 DependencyInjection/Factory/CacheAdapterFactory.php diff --git a/DependencyInjection/Factory/CacheAdapterFactory.php b/DependencyInjection/Factory/CacheAdapterFactory.php new file mode 100644 index 0000000..a07654a --- /dev/null +++ b/DependencyInjection/Factory/CacheAdapterFactory.php @@ -0,0 +1,51 @@ + + */ +class CacheAdapterFactory implements AdapterFactoryInterface +{ + /** + * {@inheritDoc} + */ + public function create(ContainerBuilder $container, $id, array $config) + { + $container + ->setDefinition($id, new DefinitionDecorator('knp_gaufrette.adapter.cache')) + ->addArgument(new Reference('gaufrette.' . $config['source'] . '_adapter')) + ->addArgument(new Reference('gaufrette.' . $config['cache'] . '_adapter')) + ->addArgument($config['ttl']) + ; + } + + /** + * {@inheritDoc} + */ + public function getKey() + { + return 'cache'; + } + + /** + * {@inheritDoc} + */ + public function addConfiguration(NodeDefinition $node) + { + $node + ->children() + ->scalarNode('source')->isRequired()->cannotBeEmpty()->end() + ->scalarNode('cache')->isRequired()->cannotBeEmpty()->end() + ->scalarNode('ttl')->defaultValue(0)->end() + ->end() + ; + } +} diff --git a/Resources/config/adapter_factories.xml b/Resources/config/adapter_factories.xml index 6adc9b2..4d52403 100644 --- a/Resources/config/adapter_factories.xml +++ b/Resources/config/adapter_factories.xml @@ -35,6 +35,9 @@ + + + diff --git a/Resources/config/gaufrette.xml b/Resources/config/gaufrette.xml index c901c08..20f3313 100644 --- a/Resources/config/gaufrette.xml +++ b/Resources/config/gaufrette.xml @@ -31,6 +31,7 @@ +