Completed
Push — 1.0 ( 524e82...63e1f6 )
by Cedric
12s
created

AbstractLoaderFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 3
c 1
b 1
f 0
lcom 1
cbo 4
dl 0
loc 39
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getChildLoaderDefinition() 0 7 2
A setTaggedLoaderDefinition() 0 13 1
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\Loader;
13
14
use Symfony\Component\DependencyInjection\ChildDefinition;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
use Symfony\Component\DependencyInjection\Definition;
17
use Symfony\Component\DependencyInjection\DefinitionDecorator;
18
19
abstract class AbstractLoaderFactory implements LoaderFactoryInterface
20
{
21
    /**
22
     * @var string
23
     */
24
    protected static $namePrefix = 'liip_imagine.binary.loader';
25
26
    /**
27
     * @return ChildDefinition|DefinitionDecorator
28
     */
29
    final protected function getChildLoaderDefinition()
30
    {
31
        $parent = sprintf('%s.prototype.%s', static::$namePrefix, $this->getName());
32
33
        return class_exists('\Symfony\Component\DependencyInjection\ChildDefinition') ?
34
            new ChildDefinition($parent) : new DefinitionDecorator($parent);
0 ignored issues
show
Deprecated Code introduced by
The class Symfony\Component\Depend...ion\DefinitionDecorator has been deprecated with message: The DefinitionDecorator class is deprecated since version 3.3 and will be removed in 4.0. Use the Symfony\Component\DependencyInjection\ChildDefinition class instead.

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.

Loading history...
35
    }
36
37
    /**
38
     * @param string           $name
39
     * @param Definition       $definition
40
     * @param ContainerBuilder $container
41
     *
42
     * @return string
43
     */
44
    final protected function setTaggedLoaderDefinition($name, Definition $definition, ContainerBuilder $container)
45
    {
46
        $definition->addTag(static::$namePrefix, array(
47
            'loader' => $name,
48
        ));
49
50
        $container->setDefinition(
51
            $id = sprintf('%s.%s', static::$namePrefix, $name),
52
            $definition
53
        );
54
55
        return $id;
56
    }
57
}
58