Merge remote-tracking branch 'RobinvdVleuten/master' into cache-adapter
Conflicts: Resources/config/gaufrette.xml
This commit is contained in:
commit
dc98b98d3d
53
DependencyInjection/Factory/CacheAdapterFactory.php
Normal file
53
DependencyInjection/Factory/CacheAdapterFactory.php
Normal 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()
|
||||||
|
;
|
||||||
|
}
|
||||||
|
}
|
|
@ -35,6 +35,9 @@
|
||||||
<service id="knp_gaufrette.adapter.factory.apc" class="Knp\Bundle\GaufretteBundle\DependencyInjection\Factory\ApcAdapterFactory">
|
<service id="knp_gaufrette.adapter.factory.apc" class="Knp\Bundle\GaufretteBundle\DependencyInjection\Factory\ApcAdapterFactory">
|
||||||
<tag name="gaufrette.adapter.factory" />
|
<tag name="gaufrette.adapter.factory" />
|
||||||
</service>
|
</service>
|
||||||
|
<service id="knp_gaufrette.adapter.factory.cache" class="Knp\Bundle\GaufretteBundle\DependencyInjection\Factory\CacheAdapterFactory">
|
||||||
|
<tag name="gaufrette.adapter.factory" />
|
||||||
|
</service>
|
||||||
|
|
||||||
</services>
|
</services>
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
<argument /><!-- prefix -->
|
<argument /><!-- prefix -->
|
||||||
<argument /><!-- ttl -->
|
<argument /><!-- ttl -->
|
||||||
</service>
|
</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%">
|
<service id="knp_gaufrette.filesystem_map" class="%knp_gaufrette.filesystem_map.class%">
|
||||||
<argument /> <!-- map of filesystems -->
|
<argument /> <!-- map of filesystems -->
|
||||||
</service>
|
</service>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user