Skip to content

Commit 80c82d7

Browse files
committed
Merge branch '2.x'
* 2.x: use ChildDefinition if available
2 parents c9fb33a + c710da0 commit 80c82d7

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

DependencyInjection/Compiler/LoggerChannelPass.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Bundle\MonologBundle\DependencyInjection\Compiler;
1313

1414
use Symfony\Component\DependencyInjection\Reference;
15+
use Symfony\Component\DependencyInjection\ChildDefinition;
1516
use Symfony\Component\DependencyInjection\ContainerBuilder;
1617
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
1718
use Symfony\Component\DependencyInjection\DefinitionDecorator;
@@ -106,7 +107,12 @@ protected function processChannels($configuration)
106107
protected function createLogger($channel, $loggerId, ContainerBuilder $container)
107108
{
108109
if (!in_array($channel, $this->channels)) {
109-
$logger = new DefinitionDecorator('monolog.logger_prototype');
110+
if (class_exists('Symfony\Component\DependencyInjection\ChildDefinition')) {
111+
$logger = new ChildDefinition('monolog.logger_prototype');
112+
} else {
113+
$logger = new DefinitionDecorator('monolog.logger_prototype');
114+
}
115+
110116
$logger->replaceArgument(0, $channel);
111117
$container->setDefinition($loggerId, $logger);
112118
$this->channels[] = $channel;

0 commit comments

Comments
 (0)