Skip to content

Commit

Permalink
fix(symfony): define use_symfony_listeners (#6344)
Browse files Browse the repository at this point in the history
* fix(symfony): define use_symfony_listeners

* test
  • Loading branch information
soyuka committed May 2, 2024
1 parent 3b8a006 commit f63fd81
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/config/packages/framework.yaml
Expand Up @@ -8,6 +8,7 @@ api_platform:
docs_formats:
jsonopenapi: ['application/vnd.openapi+json']
keep_legacy_inflector: false
use_symfony_listeners: false
defaults:
extra_properties:
rfc_7807_compliant_errors: true
Expand Down
Expand Up @@ -218,6 +218,11 @@ 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']);
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Bundle/DependencyInjection/Configuration.php
Expand Up @@ -86,8 +86,8 @@ public function getConfigTreeBuilder(): TreeBuilder
->defaultValue('0.0.0')
->end()
->booleanNode('show_webby')->defaultTrue()->info('If true, show Webby on the documentation page')->end()
->booleanNode('event_listeners_backward_compatibility_layer')->defaultNull()->info('If true API Platform uses Symfony event listeners instead of providers and processors.')->end() // TODO: Add link to the documentation
->booleanNode('use_symfony_listeners')->defaultFalse()->info(sprintf('Uses Symfony event listeners instead of the %s.', MainController::class))->end() // TODO: Add link to the documentation
->booleanNode('event_listeners_backward_compatibility_layer')->defaultNull()->info('If true API Platform uses Symfony event listeners instead of providers and processors.')->end()
->booleanNode('use_symfony_listeners')->defaultNull()->info(sprintf('Uses Symfony event listeners instead of the %s.', MainController::class))->end()
->scalarNode('name_converter')->defaultNull()->info('Specify a name converter to use.')->end()
->scalarNode('asset_package')->defaultNull()->info('Specify an asset package name to use.')->end()
->scalarNode('path_segment_name_generator')->defaultValue('api_platform.metadata.path_segment_name_generator.underscore')->info('Specify a path name generator to use.')->end()
Expand Down

0 comments on commit f63fd81

Please sign in to comment.