Skip to content

Commit fcbb056

Browse files
committed
Conditionally set listeners and commands as public for symfony versions < 3.3
1 parent f3c2476 commit fcbb056

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/DependencyInjection/SentryExtension.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@
44

55
use Sentry\ClientBuilderInterface;
66
use Sentry\Options;
7+
use Sentry\SentryBundle\Command\SentryTestCommand;
78
use Sentry\SentryBundle\ErrorTypesParser;
9+
use Sentry\SentryBundle\EventListener\ConsoleListener;
810
use Sentry\SentryBundle\EventListener\ErrorListener;
11+
use Sentry\SentryBundle\EventListener\RequestListener;
12+
use Sentry\SentryBundle\EventListener\SubRequestListener;
913
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
1014
use Symfony\Component\Config\FileLocator;
1115
use Symfony\Component\Console\ConsoleEvents;
@@ -14,6 +18,7 @@
1418
use Symfony\Component\DependencyInjection\Loader;
1519
use Symfony\Component\DependencyInjection\Reference;
1620
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
21+
use Symfony\Component\HttpKernel\Kernel;
1722

1823
/**
1924
* This is the class that loads and manages your bundle configuration
@@ -44,6 +49,7 @@ public function load(array $configs, ContainerBuilder $container)
4449
}
4550

4651
$this->tagConsoleErrorListener($container);
52+
$this->setLegacyVisibilities($container);
4753
}
4854

4955
private function passConfigurationToOptions(ContainerBuilder $container, array $processedConfiguration): void
@@ -147,4 +153,18 @@ private function tagConsoleErrorListener(ContainerBuilder $container): void
147153

148154
$listener->addTag('kernel.event_listener', $tagAttributes);
149155
}
156+
157+
/**
158+
* BC layer for symfony < 3.3, listeners and commands must be public
159+
*/
160+
private function setLegacyVisibilities(ContainerBuilder $container): void
161+
{
162+
if (Kernel::VERSION_ID < 30300) {
163+
$container->getDefinition(SentryTestCommand::class)->setPublic(true);
164+
$container->getDefinition(ConsoleListener::class)->setPublic(true);
165+
$container->getDefinition(ErrorListener::class)->setPublic(true);
166+
$container->getDefinition(RequestListener::class)->setPublic(true);
167+
$container->getDefinition(SubRequestListener::class)->setPublic(true);
168+
}
169+
}
150170
}

0 commit comments

Comments
 (0)