Skip to content

Commit

Permalink
fix(symfony): use_symfony_listeners before registering services
Browse files Browse the repository at this point in the history
  • Loading branch information
soyuka committed May 3, 2024
1 parent 58e4ed4 commit 4d46655
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php
Expand Up @@ -114,6 +114,13 @@ public function load(array $configs, ContainerBuilder $container): void
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);

if (null === $config['use_symfony_listeners']) {
$config['use_symfony_listeners'] = true;
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.');
}

$container->setParameter('api_platform.use_symfony_listeners', $config['use_symfony_listeners']);

if (!$config['formats']) {
trigger_deprecation('api-platform/core', '3.2', 'Setting the "formats" section will be mandatory in API Platform 4.');
$config['formats'] = [
Expand Down Expand Up @@ -218,14 +225,8 @@ private function registerCommonConfiguration(ContainerBuilder $container, array
$loader->load('symfony/uid.xml');
}

if (null === $config['use_symfony_listeners']) {
$config['use_symfony_listeners'] = true;
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.');
}

// TODO: remove in 4.x
$container->setParameter('api_platform.event_listeners_backward_compatibility_layer', $config['event_listeners_backward_compatibility_layer']);
$container->setParameter('api_platform.use_symfony_listeners', $config['use_symfony_listeners']);

if ($config['event_listeners_backward_compatibility_layer']) {
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(', ', [
Expand Down

0 comments on commit 4d46655

Please sign in to comment.