|
27 | 27 | use Sentry\SentryBundle\Tracing\Twig\TwigTracingExtension; |
28 | 28 | use Sentry\Serializer\RepresentationSerializer; |
29 | 29 | use Sentry\Serializer\Serializer; |
| 30 | +use Sentry\Transport\TransportFactoryInterface; |
30 | 31 | use Symfony\Bundle\TwigBundle\TwigBundle; |
31 | 32 | use Symfony\Component\Cache\CacheItem; |
32 | 33 | use Symfony\Component\Config\FileLocator; |
|
37 | 38 | use Symfony\Component\ErrorHandler\Error\FatalError; |
38 | 39 | use Symfony\Component\HttpKernel\DependencyInjection\ConfigurableExtension; |
39 | 40 |
|
| 41 | +use function array_filter; |
| 42 | +use function array_map; |
| 43 | +use function array_unshift; |
| 44 | +use function class_exists; |
| 45 | + |
40 | 46 | final class SentryExtension extends ConfigurableExtension |
41 | 47 | { |
42 | 48 | /** |
@@ -124,14 +130,22 @@ private function registerConfiguration(ContainerBuilder $container, array $confi |
124 | 130 | ->setPublic(false) |
125 | 131 | ->setArgument(0, new Reference('sentry.client.options')); |
126 | 132 |
|
| 133 | + $loggerReference = null === $config['logger'] |
| 134 | + ? new Reference(NullLogger::class, ContainerBuilder::IGNORE_ON_INVALID_REFERENCE) |
| 135 | + : new Reference($config['logger']); |
| 136 | + |
| 137 | + $factoryBuilderDefinition = $container->getDefinition(TransportFactoryInterface::class); |
| 138 | + $factoryBuilderDefinition->setArgument('$httpClient', null); |
| 139 | + $factoryBuilderDefinition->setArgument('$logger', $loggerReference); |
| 140 | + |
127 | 141 | $clientBuilderDefinition = (new Definition(ClientBuilder::class)) |
128 | 142 | ->setArgument(0, new Reference('sentry.client.options')) |
129 | 143 | ->addMethodCall('setSdkIdentifier', [SentryBundle::SDK_IDENTIFIER]) |
130 | 144 | ->addMethodCall('setSdkVersion', [PrettyVersions::getVersion('sentry/sentry-symfony')->getPrettyVersion()]) |
131 | 145 | ->addMethodCall('setTransportFactory', [new Reference($config['transport_factory'])]) |
132 | 146 | ->addMethodCall('setSerializer', [$serializer]) |
133 | 147 | ->addMethodCall('setRepresentationSerializer', [$representationSerializerDefinition]) |
134 | | - ->addMethodCall('setLogger', [null !== $config['logger'] ? new Reference($config['logger']) : new Reference(NullLogger::class, ContainerBuilder::IGNORE_ON_INVALID_REFERENCE)]); |
| 148 | + ->addMethodCall('setLogger', [$loggerReference]); |
135 | 149 |
|
136 | 150 | $container |
137 | 151 | ->setDefinition('sentry.client', new Definition(Client::class)) |
|
0 commit comments