Completed
Pull Request — 1.0 (#875)
by Rob
02:22
created

AbstractCompilerPass::setDefinitionSharing()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 5
nc 2
nop 2
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\Compiler;
13
14
use Liip\ImagineBundle\Utility\Framework\SymfonyFramework;
15
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
16
use Symfony\Component\DependencyInjection\ContainerBuilder;
17
use Symfony\Component\DependencyInjection\Definition;
18
19
abstract class AbstractCompilerPass implements CompilerPassInterface
20
{
21
    /**
22
     * @param ContainerBuilder $container
23
     * @param string           $message
24
     * @param mixed[]          $replacements
25
     */
26
    protected function log(ContainerBuilder $container, $message, array $replacements = array())
27
    {
28
        if (count($replacements) > 0) {
29
            $message = vsprintf($message, $replacements);
30
        }
31
32
        if (SymfonyFramework::hasDirectContainerBuilderLogging()) {
33
            $container->log($this, $message);
34
        } else {
35
            $compiler = $container->getCompiler();
36
            $compiler->addLogMessage($compiler->getLoggingFormatter()->format($this, $message));
0 ignored issues
show
Deprecated Code introduced by
The method Symfony\Component\Depend...::getLoggingFormatter() has been deprecated with message: since version 3.3, to be removed in 4.0. Use the ContainerBuilder::log() method instead.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
Deprecated Code introduced by
The method Symfony\Component\Depend...mpiler::addLogMessage() has been deprecated with message: since version 3.3, to be removed in 4.0. Use the ContainerBuilder::log() method instead.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
37
        }
38
    }
39
40
    /**
41
     * @param Definition $definition
42
     * @param bool       $enable
43
     */
44
    protected function setDefinitionSharing(Definition $definition, $enable)
45
    {
46
        if (SymfonyFramework::hasDefinitionSharing()) {
47
            $definition->setShared($enable);
48
        } else {
49
            $definition->setScope($enable ? 'container' : 'prototype');
0 ignored issues
show
Bug introduced by
The method setScope() does not seem to exist on object<Symfony\Component...cyInjection\Definition>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
50
        }
51
    }
52
}
53