10000 [FrameworkBundle] Add support for signal plain name in the `messenger… · symfony/symfony@0092092 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0092092

Browse files
[FrameworkBundle] Add support for signal plain name in the messenger.stop_worker_on_signals configuration
1 parent 3918524 commit 0092092

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ CHANGELOG
1111
* Deprecate the `--show-arguments` option of the `container:debug` command, as arguments are now always shown
1212
* Add `RateLimiterFactoryInterface` as an alias of the `limiter` service
1313
* Add `framework.validation.disable_translation` option
14+
* Add support for signal plain name in the `messenger.stop_worker_on_signals` configuration
1415

1516
7.2
1617
---

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1572,6 +1572,7 @@ private function addMessengerSection(ArrayNodeDefinition $rootNode, callable $en
15721572
->{$enableIfStandalone('symfony/messenger', MessageBusInterface::class)}()
15731573
->fixXmlConfig('transport')
15741574
->fixXmlConfig('bus', 'buses')
1575+
->fixXmlConfig('stop_worker_on_signal')
15751576
->validate()
15761577
->ifTrue(fn ($v) => isset($v['buses']) && \count($v['buses']) > 1 && null === $v['default_bus'])
15771578
->thenInvalid('You must specify the "default_bus" if you define more than one bus.')
@@ -1704,7 +1705,18 @@ function ($a) {
17041705
->arrayNode('stop_worker_on_signals')
17051706
->defaultValue([])
17061707
->info('A list of signals that should stop the worker; defaults to SIGTERM and SIGINT.')
1707-
->integerPrototype()->end()
1708+
->beforeNormalization()
1709+
->always(function ($v) {
1710+
return array_map(static function ($element) {
1711+
if (\is_string($element) && str_starts_with($element, 'SIG') && \array_key_exists($element, get_defined_constants(true)['pcntl'])) {
1712+
return \constant($element);
1713+
}
1714+
1715+
return $element;
1716+
}, $v);
1717+
})
1718+
->end()
1719+
->scalarPrototype()->end()
17081720
->end()
17091721
->scalarNode('default_bus')->defaultNull()->end()
17101722
->arrayNode('buses')

src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,7 @@
609609
<xsd:element name="routing" type="messenger_routing" minOccurs="0" maxOccurs="unbounded" />
610610
<xsd:element name="transport" type="messenger_transport" minOccurs="0" maxOccurs="unbounded" />
611611
<xsd:element name="bus" type="messenger_bus" minOccurs="0" maxOccurs="unbounded" />
612+
<xsd:element name="stop-worker-on-signal" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
612613
</xsd:sequence>
613614
<xsd:attribute name="default-bus" type="xsd:string" />
614615
<xsd:attribute name="enabled" type="xsd:boolean" />

0 commit comments

Comments
 (0)
0