Skip to content

Commit 194df55

Browse files
committed
minor #197 Add a better detection of the deprecation case (stof)
This PR was merged into the 2.x branch. Discussion ---------- Add a better detection of the deprecation case We should not trigger the deprecation when using a Symfony version not using the new feature Commits ------- ae3762c Add a better detection of the deprecation case
2 parents d148888 + ae3762c commit 194df55

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

DependencyInjection/Compiler/DebugHandlerPass.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Bundle\MonologBundle\DependencyInjection\Compiler;
1313

14-
@trigger_error('The '.__NAMESPACE__.'\DebugHandlerPass class is deprecated since version 2.12 and will be removed in 3.0. Use AddDebugLogProcessorPass in FrameworkBundle instead.', E_USER_DEPRECATED);
1514

1615
use Symfony\Component\DependencyInjection\Reference;
1716
use Symfony\Component\DependencyInjection\ContainerBuilder;
@@ -33,6 +32,11 @@ class DebugHandlerPass implements CompilerPassInterface
3332

3433
public function __construct(LoggerChannelPass $channelPass)
3534
{
35+
// Trigger the deprecation only when using a Symfony version supporting the new feature
36+
if (class_exists('Symfony\Bridge\Monolog\Processor\DebugProcessor') && class_exists('Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddDebugLogProcessorPass')) {
37+
@trigger_error('The '.__CLASS__.' class is deprecated since version 2.12 and will be removed in 3.0. Use AddDebugLogProcessorPass in FrameworkBundle instead.', E_USER_DEPRECATED);
38+
}
39+
3640
$this->channelPass = $channelPass;
3741
}
3842

MonologBundle.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function build(ContainerBuilder $container)
3434
parent::build($container);
3535

3636
$container->addCompilerPass($channelPass = new LoggerChannelPass());
37-
if (!class_exists('Symfony\Bridge\Monolog\Processor\DebugProcessor')) {
37+
if (!class_exists('Symfony\Bridge\Monolog\Processor\DebugProcessor') || !class_exists('Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddDebugLogProcessorPass')) {
3838
$container->addCompilerPass(new DebugHandlerPass($channelPass));
3939
}
4040
$container->addCompilerPass(new FixEmptyLoggerPass($channelPass));

0 commit comments

Comments
 (0)