Initial commit
This commit is contained in:
60
DependencyInjection/Factory/InMemoryAdapterFactory.php
Normal file
60
DependencyInjection/Factory/InMemoryAdapterFactory.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace Knplabs\Bundle\GaufretteBundle\DependencyInjection\Factory;
|
||||
|
||||
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\DefinitionDecorator;
|
||||
|
||||
/**
|
||||
* In memory adapter factory
|
||||
*
|
||||
* @author Antoine Hérault <antoine.herault@gmail.com>
|
||||
*/
|
||||
class InMemoryAdapterFactory implements AdapterFactoryInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function create(ContainerBuilder $container, $id, array $config)
|
||||
{
|
||||
$adapter = sprintf('knplabs_gaufrette.adapter.local.%s', $id);
|
||||
|
||||
$container
|
||||
->setDefinition($adapter, new DefinitionDecorator('knplabs_gaufrette.adapter.in_memory'))
|
||||
->replaceArgument(0, $config['files'])
|
||||
;
|
||||
|
||||
return $adapter;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getKey()
|
||||
{
|
||||
return 'in_memory';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function addConfiguration(NodeDefinition $node)
|
||||
{
|
||||
$node
|
||||
->children()
|
||||
->arrayNode('files')
|
||||
->fixXmlConfig('file')
|
||||
->useAttributeAsKey('filename')
|
||||
->prototype('array')
|
||||
->children()
|
||||
->scalarNode('content')->end()
|
||||
->scalarNode('checksum')->end()
|
||||
->scalarNode('mtime')->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user