Skip to content

Commit 23c4e9b

Browse files
author
Robin Chalas
committed
Merge branch '4.3' into 4.4
* 4.3: [FWBundle] Remove unused parameter [Intl] [Workflow] fixes English grammar typos [Filesystem] [Serializer] fixes English grammar typo [Messenger] Adding exception to amqp transport in case amqp ext is not installed [Monolog Bridge] Fixed accessing static property as non static. Improve Symfony description Add DateTimeZoneNormalizer into Dependency Injection [Messenger] Error when specified default bus is not among the configured [Validator] Add Japanese translation [Workflow] Apply the same logic of precedence between the apply() and the buildTransitionBlockerList() method Remove some unused methods parameters Avoid empty \"If-Modified-Since\" header in validation request [Security] Fix SwitchUser is broken when the User Provider always returns a valid user Fix error message according to the new regex compatibility with DoctrineBundle 2 [Validator] ConstraintValidatorTestCase: add missing return value to mocked validate method calls
2 parents a055293 + a2aa301 commit 23c4e9b

File tree

4 files changed

+33
-2
lines changed

4 files changed

+33
-2
lines changed

DependencyInjection/Configuration.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
2020
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
2121
use Symfony\Component\Config\Definition\ConfigurationInterface;
22+
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
2223
use Symfony\Component\DependencyInjection\Exception\LogicException;
2324
use Symfony\Component\Form\Form;
2425
use Symfony\Component\HttpClient\HttpClient;
@@ -1173,6 +1174,10 @@ private function addMessengerSection(ArrayNodeDefinition $rootNode)
11731174
->ifTrue(function ($v) { return isset($v['buses']) && \count($v['buses']) > 1 && null === $v['default_bus']; })
11741175
->thenInvalid('You must specify the "default_bus" if you define more than one bus.')
11751176
->end()
1177+
->validate()
1178+
->ifTrue(static function ($v): bool { return isset($v['buses']) && null !== $v['default_bus'] && !isset($v['buses'][$v['default_bus']]); })
1179+
->then(static function (array $v): void { throw new InvalidConfigurationException(sprintf('The specified default bus "%s" is not configured. Available buses are "%s".', $v['default_bus'], implode('", "', array_keys($v['buses'])))); })
1180+
->end()
11761181
->children()
11771182
->arrayNode('routing')
11781183
->normalizeKeys(false)

DependencyInjection/FrameworkExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ public function load(array $configs, ContainerBuilder $container)
304304
}
305305

306306
if ($this->messengerConfigEnabled = $this->isConfigEnabled($container, $config['messenger'])) {
307-
$this->registerMessengerConfiguration($config['messenger'], $container, $loader, $config['serializer'], $config['validation']);
307+
$this->registerMessengerConfiguration($config['messenger'], $container, $loader, $config['validation']);
308308
} else {
309309
$container->removeDefinition('console.command.messenger_consume_messages');
310310
$container->removeDefinition('console.command.messenger_debug');
@@ -1696,7 +1696,7 @@ private function registerLockConfiguration(array $config, ContainerBuilder $cont
16961696
}
16971697
}
16981698

1699-
private function registerMessengerConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader, array $serializerConfig, array $validationConfig)
1699+
private function registerMessengerConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader, array $validationConfig)
17001700
{
17011701
if (!interface_exists(MessageBusInterface::class)) {
17021702
throw new LogicException('Messenger support cannot be enabled as the Messenger component is not installed. Try running "composer require symfony/messenger".');

Resources/config/serializer.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@
4040
<tag name="serializer.normalizer" priority="-915" />
4141
</service>
4242

43+
<service id="serializer.normalizer.datetimezone" class="Symfony\Component\Serializer\Normalizer\DateTimeZoneNormalizer">
44+
<!-- Run before serializer.normalizer.object -->
45+
<tag name="serializer.normalizer" priority="-915" />
46+
</service>
47+
4348
<service id="serializer.normalizer.dateinterval" class="Symfony\Component\Serializer\Normalizer\DateIntervalNormalizer">
4449
<!-- Run before serializer.normalizer.object -->
4550
<tag name="serializer.normalizer" priority="-915" />

Tests/DependencyInjection/ConfigurationTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,27 @@ public function testBusMiddlewareDontMerge()
329329
);
330330
}
331331

332+
public function testItErrorsWhenDefaultBusDoesNotExist()
333+
{
334+
$processor = new Processor();
335+
$configuration = new Configuration(true);
336+
337+
$this->expectException(InvalidConfigurationException::class);
338+
$this->expectExceptionMessage('The specified default bus "foo" is not configured. Available buses are "bar", "baz".');
339+
340+
$processor->processConfiguration($configuration, [
341+
[
342+
'messenger' => [
343+
'default_bus' => 'foo',
344+
'buses' => [
345+
'bar' => null,
346+
'baz' => null,
347+
],
348+
],
349+
],
350+
]);
351+
}
352+
332353
protected static function getBundleDefaultConfig()
333354
{
334355
return [

0 commit comments

Comments
 (0)