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 @@ +