|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the `liip/LiipImagineBundle` project. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) https://github.com/liip/LiipImagineBundle/graphs/contributors |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE.md |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Liip\ImagineBundle\DependencyInjection\Factory\Resolver; |
|
13
|
|
|
|
|
14
|
|
|
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; |
|
15
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
16
|
|
|
use Symfony\Component\DependencyInjection\Reference; |
|
17
|
|
|
|
|
18
|
|
View Code Duplication |
class FlysystemV2ResolverFactory extends AbstractResolverFactory |
|
|
|
|
|
|
19
|
|
|
{ |
|
20
|
|
|
/** |
|
21
|
|
|
* {@inheritdoc} |
|
22
|
|
|
*/ |
|
23
|
|
|
public function create(ContainerBuilder $container, $resolverName, array $config) |
|
24
|
|
|
{ |
|
25
|
|
|
$resolverDefinition = $this->getChildResolverDefinition(); |
|
26
|
|
|
$resolverDefinition->replaceArgument(0, new Reference($config['filesystem_service'])); |
|
27
|
|
|
$resolverDefinition->replaceArgument(2, $config['root_url']); |
|
28
|
|
|
$resolverDefinition->replaceArgument(3, $config['cache_prefix']); |
|
29
|
|
|
$resolverDefinition->replaceArgument(4, $config['visibility']); |
|
30
|
|
|
$resolverDefinition->addTag('liip_imagine.cache.resolver', [ |
|
31
|
|
|
'resolver' => $resolverName, |
|
32
|
|
|
]); |
|
33
|
|
|
|
|
34
|
|
|
$resolverId = 'liip_imagine.cache.resolver.'.$resolverName; |
|
35
|
|
|
$container->setDefinition($resolverId, $resolverDefinition); |
|
36
|
|
|
|
|
37
|
|
|
return $resolverId; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* {@inheritdoc} |
|
42
|
|
|
*/ |
|
43
|
|
|
public function getName() |
|
44
|
|
|
{ |
|
45
|
|
|
return 'flysystem2'; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* {@inheritdoc} |
|
50
|
|
|
*/ |
|
51
|
|
|
public function addConfiguration(ArrayNodeDefinition $builder) |
|
52
|
|
|
{ |
|
53
|
|
|
$builder |
|
54
|
|
|
->children() |
|
55
|
|
|
->scalarNode('filesystem_service') |
|
56
|
|
|
->isRequired() |
|
57
|
|
|
->cannotBeEmpty() |
|
58
|
|
|
->end() |
|
59
|
|
|
->scalarNode('cache_prefix') |
|
60
|
|
|
->defaultValue(null) |
|
61
|
|
|
->end() |
|
62
|
|
|
->scalarNode('root_url') |
|
63
|
|
|
->isRequired() |
|
64
|
|
|
->cannotBeEmpty() |
|
65
|
|
|
->end() |
|
66
|
|
|
->enumNode('visibility') |
|
67
|
|
|
->values(['public', 'private']) |
|
68
|
|
|
->defaultValue('public') |
|
69
|
|
|
->end() |
|
70
|
|
|
->end(); |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.