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)); |
|
|
|
|
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'); |
|
|
|
|
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
|
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.