Completed
Pull Request — master (#732)
by 12345
03:41
created

WebPathResolverFactory::getName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %
Metric Value
dl 4
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Liip\ImagineBundle\DependencyInjection\Factory\Resolver;
4
5
use Symfony\Component\DependencyInjection\ContainerBuilder;
6
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
7
use Symfony\Component\DependencyInjection\DefinitionDecorator;
8
9 View Code Duplication
class WebPathResolverFactory implements ResolverFactoryInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

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.

Loading history...
10
{
11
    /**
12
     * {@inheritdoc}
13
     */
14
    public function create(ContainerBuilder $container, $resolverName, array $config)
15
    {
16
        $resolverDefinition = new DefinitionDecorator('liip_imagine.cache.resolver.prototype.web_path');
17
        $resolverDefinition->replaceArgument(2, $config['web_root']);
18
        $resolverDefinition->replaceArgument(3, $config['cache_prefix']);
19
        $resolverDefinition->addTag('liip_imagine.cache.resolver', array(
20
            'resolver' => $resolverName,
21
        ));
22
        $resolverId = 'liip_imagine.cache.resolver.'.$resolverName;
23
24
        $container->setDefinition($resolverId, $resolverDefinition);
25
26
        return $resolverId;
27
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function getName()
33
    {
34
        return 'web_path';
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    public function addConfiguration(ArrayNodeDefinition $builder)
41
    {
42
        $builder
43
            ->children()
44
                ->scalarNode('web_root')->defaultValue('%kernel.root_dir%/../web')->cannotBeEmpty()->end()
45
                ->scalarNode('cache_prefix')->defaultValue('media/cache')->cannotBeEmpty()->end()
46
            ->end()
47
        ;
48
    }
49
}
50