|
9 | 9 | use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
|
10 | 10 | use Symfony\Component\Config\FileLocator;
|
11 | 11 | use Symfony\Component\DependencyInjection\ContainerBuilder;
|
| 12 | +use Symfony\Component\DependencyInjection\Definition; |
12 | 13 | use Symfony\Component\DependencyInjection\Loader;
|
13 | 14 | use Symfony\Component\DependencyInjection\Reference;
|
14 | 15 | use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
@@ -86,25 +87,27 @@ private function passConfigurationToOptions(ContainerBuilder $container, array $
|
86 | 87 | }
|
87 | 88 |
|
88 | 89 | if (\array_key_exists('before_send', $processedOptions)) {
|
89 |
| - $optionValue = $processedOptions['before_send']; |
90 |
| - if (is_string($optionValue) && 0 === strpos($optionValue, '@')) { |
91 |
| - $beforeSend = new Reference(substr($optionValue, 1)); |
92 |
| - } else { |
93 |
| - $beforeSend = $optionValue; |
94 |
| - } |
95 |
| - |
96 |
| - $options->addMethodCall('setBeforeSendCallback', [$beforeSend]); |
| 90 | + $this->mapCallableValue($options, 'setBeforeSendCallback', $processedOptions['before_send']); |
97 | 91 | }
|
98 | 92 |
|
99 | 93 | if (\array_key_exists('before_breadcrumb', $processedOptions)) {
|
100 |
| - $optionValue = $processedOptions['before_breadcrumb']; |
101 |
| - if (is_string($optionValue) && 0 === strpos($optionValue, '@')) { |
102 |
| - $beforeSend = new Reference(substr($optionValue, 1)); |
103 |
| - } else { |
104 |
| - $beforeSend = $optionValue; |
105 |
| - } |
| 94 | + $this->mapCallableValue($options, 'setBeforeBreadcrumbCallback', $processedOptions['before_breadcrumb']); |
| 95 | + } |
| 96 | + } |
106 | 97 |
|
107 |
| - $options->addMethodCall('setBeforeBreadcrumbCallback', [$beforeSend]); |
| 98 | + /** |
| 99 | + * @param Definition $options |
| 100 | + * @param string $method |
| 101 | + * @param callable|string $optionValue |
| 102 | + */ |
| 103 | + private function mapCallableValue(Definition $options, string $method, $optionValue): void |
| 104 | + { |
| 105 | + if (is_string($optionValue) && 0 === strpos($optionValue, '@')) { |
| 106 | + $beforeSend = new Reference(substr($optionValue, 1)); |
| 107 | + } else { |
| 108 | + $beforeSend = $optionValue; |
108 | 109 | }
|
| 110 | + |
| 111 | + $options->addMethodCall($method, [$beforeSend]); |
109 | 112 | }
|
110 | 113 | }
|
0 commit comments