/
AdapterFactory.php
38 lines (33 loc) · 1.23 KB
/
AdapterFactory.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
namespace Oneup\FlysystemBundle\DependencyInjection\Factory\Cache;
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\ChildDefinition;
use Symfony\Component\DependencyInjection\Reference;
use Oneup\FlysystemBundle\DependencyInjection\Factory\CacheFactoryInterface;
class AdapterFactory implements CacheFactoryInterface
{
public function getKey()
{
return 'adapter';
}
public function create(ContainerBuilder $container, $id, array $config)
{
$container
->setDefinition($id, new ChildDefinition('oneup_flysystem.cache.adapter'))
->replaceArgument(0, new Reference(sprintf('oneup_flysystem.%s_adapter', $config['adapter'])))
->replaceArgument(1, $config['key'])
->replaceArgument(2, $config['expires'])
;
}
public function addConfiguration(NodeDefinition $node)
{
$node
->children()
->scalarNode('adapter')->isRequired()->end()
->scalarNode('key')->defaultValue('flysystem')->end()
->scalarNode('expires')->defaultNull()->end()
->end()
;
}
}