diff --git a/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md b/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md index 49f8d634ddc07..55eeaf1fdc1f3 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md +++ b/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md @@ -11,6 +11,7 @@ CHANGELOG * Deprecate the `--show-arguments` option of the `container:debug` command, as arguments are now always shown * Add `RateLimiterFactoryInterface` as an alias of the `limiter` service * Add `framework.validation.disable_translation` option + * Add support for signal plain name in the `messenger.stop_worker_on_signals` configuration 7.2 --- diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php index 7b1cafac5360f..f5279c419f094 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php @@ -1572,6 +1572,7 @@ private function addMessengerSection(ArrayNodeDefinition $rootNode, callable $en ->{$enableIfStandalone('symfony/messenger', MessageBusInterface::class)}() ->fixXmlConfig('transport') ->fixXmlConfig('bus', 'buses') + ->fixXmlConfig('stop_worker_on_signal') ->validate() ->ifTrue(fn ($v) => isset($v['buses']) && \count($v['buses']) > 1 && null === $v['default_bus']) ->thenInvalid('You must specify the "default_bus" if you define more than one bus.') @@ -1704,7 +1705,26 @@ function ($a) { ->arrayNode('stop_worker_on_signals') ->defaultValue([]) ->info('A list of signals that should stop the worker; defaults to SIGTERM and SIGINT.') - ->integerPrototype()->end() + ->beforeNormalization() + ->always(function ($signals) { + if (!\is_array($signals)) { + throw new InvalidConfigurationException('The "stop_worker_on_signals" option must be an array in messenger configuration.'); + } + + return array_map(static function ($v) { + if (\is_string($v) && str_starts_with($v, 'SIG') && \array_key_exists($v, get_defined_constants(true)['pcntl'])) { + return \constant($v); + } + + if (!\is_int($v)) { + throw new InvalidConfigurationException('The "stop_worker_on_signals" option must be an array of pcntl signals in messenger configuration.'); + } + + return $v; + }, $signals); + }) + ->end() + ->scalarPrototype()->end() ->end() ->scalarNode('default_bus')->defaultNull()->end() ->arrayNode('buses') diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd b/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd index 2dc46beb911d1..b47de331a4775 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd @@ -609,6 +609,7 @@ +