Skip to content

Commit b498412

Browse files
authored
fix(symfony): use_symfony_listeners before registering services (#6350)
1 parent 58e4ed4 commit b498412

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,13 @@ public function load(array $configs, ContainerBuilder $container): void
114114
$configuration = new Configuration();
115115
$config = $this->processConfiguration($configuration, $configs);
116116

117+
if (null === $config['use_symfony_listeners']) {
118+
$config['use_symfony_listeners'] = true;
119+
trigger_deprecation('api-platform/core', '3.3', 'Setting the value of "use_symfony_listeners" will be mandatory in 4.0 as it will default to "false". Use "true" if you use Symfony Controllers or Event Listeners.');
120+
}
121+
122+
$container->setParameter('api_platform.use_symfony_listeners', $config['use_symfony_listeners']);
123+
117124
if (!$config['formats']) {
118125
trigger_deprecation('api-platform/core', '3.2', 'Setting the "formats" section will be mandatory in API Platform 4.');
119126
$config['formats'] = [
@@ -218,14 +225,8 @@ private function registerCommonConfiguration(ContainerBuilder $container, array
218225
$loader->load('symfony/uid.xml');
219226
}
220227

221-
if (null === $config['use_symfony_listeners']) {
222-
$config['use_symfony_listeners'] = true;
223-
trigger_deprecation('api-platform/core', '3.3', 'Setting the value of "use_symfony_listeners" will be mandatory in 4.0 as it will default to "false". Use "true" if you use Symfony Controllers or Event Listeners.');
224-
}
225-
226228
// TODO: remove in 4.x
227229
$container->setParameter('api_platform.event_listeners_backward_compatibility_layer', $config['event_listeners_backward_compatibility_layer']);
228-
$container->setParameter('api_platform.use_symfony_listeners', $config['use_symfony_listeners']);
229230

230231
if ($config['event_listeners_backward_compatibility_layer']) {
231232
trigger_deprecation('api-platform/core', '3.3', sprintf('The "event_listeners_backward_compatibility_layer" will be removed in 4.0. Use the configuration "use_symfony_listeners" to use Symfony listeners. The following listeners are deprecated and will be removed in API Platform 4.0: "%s"', implode(', ', [

0 commit comments

Comments
 (0)