CacheAdapterFactory created
This commit is contained in:
parent
b414f4f142
commit
d547add078
51
DependencyInjection/Factory/CacheAdapterFactory.php
Normal file
51
DependencyInjection/Factory/CacheAdapterFactory.php
Normal file
|
@ -0,0 +1,51 @@
|
|||
<?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'])
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@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()
|
||||
;
|
||||
}
|
||||
}
|
|
@ -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>
|
||||
|
||||
|
|
|
@ -31,6 +31,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\Bundle\GaufretteBundle\FilesystemMap">
|
||||
<argument /> <!-- map of filesystems -->
|
||||
</service>
|
||||
|
|
Loading…
Reference in New Issue
Block a user