Merge remote-tracking branch 'RobinvdVleuten/master' into cache-adapter

Conflicts:
	Resources/config/gaufrette.xml
This commit is contained in:
l3l0 2012-09-05 19:45:48 +02:00
commit dc98b98d3d
3 changed files with 57 additions and 0 deletions

View File

@ -0,0 +1,53 @@
<?php
namespace Knp\Bundle\GaufretteBundle\DependencyInjection\Factory;
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\DefinitionDecorator;
use Symfony\Component\DependencyInjection\Reference;
/**
* Cache adapter factory
*
* @author Robin van der Vleuten <robinvdvleuten@gmail.com>
*/
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'])
->addArgument($config['serialize'] ? new Reference('gaufrette.' . $config['serialize'] . '_adapter') : null)
;
}
/**
* {@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()
->scalarNode('serialize')->defaultNull()->end()
->end()
;
}
}

View File

@ -35,6 +35,9 @@
<service id="knp_gaufrette.adapter.factory.apc" class="Knp\Bundle\GaufretteBundle\DependencyInjection\Factory\ApcAdapterFactory">
<tag name="gaufrette.adapter.factory" />
</service>
<service id="knp_gaufrette.adapter.factory.cache" class="Knp\Bundle\GaufretteBundle\DependencyInjection\Factory\CacheAdapterFactory">
<tag name="gaufrette.adapter.factory" />
</service>
</services>

View File

@ -34,6 +34,7 @@
<argument /><!-- prefix -->
<argument /><!-- ttl -->
</service>
<service id="knp_gaufrette.adapter.cache" class="Gaufrette\Adapter\Cache" abstract="true" public="false" />
<service id="knp_gaufrette.filesystem_map" class="%knp_gaufrette.filesystem_map.class%">
<argument /> <!-- map of filesystems -->
</service>