1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Zenstruck\BackupBundle\DependencyInjection\Factory\Destination; |
4
|
|
|
|
5
|
|
|
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; |
6
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
7
|
|
|
use Symfony\Component\DependencyInjection\DefinitionDecorator; |
8
|
|
|
use Symfony\Component\DependencyInjection\Reference; |
9
|
|
|
use Zenstruck\BackupBundle\DependencyInjection\Factory\Factory; |
10
|
|
|
use Zenstruck\Backup\Destination\S3CmdDestination; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @author Kevin Bond <[email protected]> |
14
|
|
|
*/ |
15
|
|
|
class S3CmdDestinationFactory implements Factory |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* {@inheritdoc} |
19
|
|
|
*/ |
20
|
5 |
|
public function getName() |
21
|
|
|
{ |
22
|
5 |
|
return 's3cmd'; |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* {@inheritdoc} |
27
|
|
|
*/ |
28
|
1 |
|
public function create(ContainerBuilder $container, $id, array $config) |
29
|
|
|
{ |
30
|
1 |
|
$serviceId = sprintf('zenstruck_backup.destination.%s', $id); |
31
|
|
|
|
32
|
1 |
|
$container->setDefinition($serviceId, new DefinitionDecorator('zenstruck_backup.destination.abstract_s3cmd')) |
|
|
|
|
33
|
1 |
|
->replaceArgument(0, $id) |
34
|
1 |
|
->replaceArgument(1, $config['bucket']) |
35
|
1 |
|
->replaceArgument(2, $config['timeout']) |
36
|
1 |
|
->replaceArgument(3, $config['options']) |
37
|
1 |
|
->addTag('zenstruck_backup.destination') |
38
|
|
|
; |
39
|
|
|
|
40
|
1 |
|
return new Reference($serviceId); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* {@inheritdoc} |
45
|
|
|
*/ |
46
|
5 |
|
public function addConfiguration(ArrayNodeDefinition $builder) |
47
|
|
|
{ |
48
|
|
|
$builder |
49
|
5 |
|
->children() |
50
|
5 |
|
->scalarNode('bucket')->isRequired()->example('s3://foobar/backups')->end() |
51
|
5 |
|
->integerNode('timeout')->defaultValue(S3CmdDestination::DEFAULT_TIMEOUT)->end() |
52
|
5 |
|
->arrayNode('options') |
53
|
5 |
|
->prototype('scalar')->end() |
54
|
5 |
|
->end() |
55
|
5 |
|
->end() |
56
|
|
|
; |
57
|
5 |
|
} |
58
|
|
|
} |
59
|
|
|
|
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.