/
AwsS3V3Factory.php
40 lines (35 loc) · 1.32 KB
/
AwsS3V3Factory.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
39
40
<?php
namespace Oneup\FlysystemBundle\DependencyInjection\Factory\Adapter;
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\AdapterFactoryInterface;
class AwsS3V3Factory implements AdapterFactoryInterface
{
public function getKey()
{
return 'awss3v3';
}
public function create(ContainerBuilder $container, $id, array $config)
{
$definition = $container
->setDefinition($id, new ChildDefinition('oneup_flysystem.adapter.awss3v3'))
->replaceArgument(0, new Reference($config['client']))
->replaceArgument(1, $config['bucket'])
->replaceArgument(2, $config['prefix'])
->addArgument((array) $config['options'])
;
}
public function addConfiguration(NodeDefinition $node)
{
$node
->children()
->scalarNode('client')->isRequired()->end()
->scalarNode('bucket')->isRequired()->end()
->scalarNode('prefix')->defaultNull()->end()
->arrayNode('options')->prototype('scalar')->end()
->end()
;
}
}