From 648bc2b34217214b590da7537ca7a6034034af0f Mon Sep 17 00:00:00 2001 From: Alexander Deruwe Date: Mon, 12 Dec 2011 22:25:17 +0100 Subject: [PATCH] Implement APC adapter --- .../Factory/ApcAdapterFactory.php | 48 +++++++++++++++++++ README.markdown | 23 +++++++++ Resources/config/adapter_factories.xml | 3 ++ Resources/config/gaufrette.xml | 4 ++ 4 files changed, 78 insertions(+) create mode 100644 DependencyInjection/Factory/ApcAdapterFactory.php diff --git a/DependencyInjection/Factory/ApcAdapterFactory.php b/DependencyInjection/Factory/ApcAdapterFactory.php new file mode 100644 index 0000000..7642bf3 --- /dev/null +++ b/DependencyInjection/Factory/ApcAdapterFactory.php @@ -0,0 +1,48 @@ + + */ +class ApcAdapterFactory implements AdapterFactoryInterface +{ + /** + * {@inheritDoc} + */ + public function create(ContainerBuilder $container, $id, array $config) + { + $container + ->setDefinition($id, new DefinitionDecorator('knp_gaufrette.adapter.apc')) + ->replaceArgument(0, $config['prefix']) + ->replaceArgument(1, $config['ttl']) + ; + } + + /** + * {@inheritDoc} + */ + public function getKey() + { + return 'apc'; + } + + /** + * {@inheritDoc} + */ + public function addConfiguration(NodeDefinition $node) + { + $node + ->children() + ->scalarNode('prefix')->isRequired()->cannotBeEmpty()->end() + ->scalarNode('ttl')->defaultValue(0)->end() + ->end() + ; + } +} diff --git a/README.markdown b/README.markdown index 7b9a3b7..417054a 100644 --- a/README.markdown +++ b/README.markdown @@ -315,3 +315,26 @@ knp_gaufrette: create: true mode: FTP_BINARY ``` + +## Apc + +Adapter for APC. + +A non-persistent adapter, use it in the dev environment, in demo sites, ... + +### Parameters + + * `prefix` The prefix to this filesystem (APC 'namespace', it is recommended that this end in a dot '.') *(required)* + * `ttl` Time to live *(default 0)* + +### Example + +``` yaml +# app/config/config.yml +knp_gaufrette: + adapters: + foo: + apc: + prefix: APC 'namespace' prefix + ttl: 0 +``` diff --git a/Resources/config/adapter_factories.xml b/Resources/config/adapter_factories.xml index 1ecddc5..6adc9b2 100644 --- a/Resources/config/adapter_factories.xml +++ b/Resources/config/adapter_factories.xml @@ -32,6 +32,9 @@ + + + diff --git a/Resources/config/gaufrette.xml b/Resources/config/gaufrette.xml index dc75fef..c901c08 100644 --- a/Resources/config/gaufrette.xml +++ b/Resources/config/gaufrette.xml @@ -27,6 +27,10 @@ + + + +