Skip to content

Commit 6d66143

Browse files
committed
Merge branch '6.4' into 7.2
* 6.4: [Messenger] Filter out non-consumable receivers when registering `ConsumeMessagesCommand` [Mailer] fix multiple transports default injection [Mailer][Postmark] Set CID for attachments when it exists
2 parents 53cad5c + 078a6f1 commit 6d66143

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

DependencyInjection/FrameworkExtension.php

+8-5
Original file line numberDiff line numberDiff line change
@@ -2256,13 +2256,17 @@ private function registerMessengerConfiguration(array $config, ContainerBuilder
22562256
$transportRateLimiterReferences = [];
22572257
foreach ($config['transports'] as $name => $transport) {
22582258
$serializerId = $transport['serializer'] ?? 'messenger.default_serializer';
2259+
$tags = [
2260+
'alias' => $name,
2261+
'is_failure_transport' => \in_array($name, $failureTransports, true),
2262+
];
2263+
if (str_starts_with($transport['dsn'], 'sync://')) {
2264+
$tags['is_consumable'] = false;
2265+
}
22592266
$transportDefinition = (new Definition(TransportInterface::class))
22602267
->setFactory([new Reference('messenger.transport_factory'), 'createTransport'])
22612268
->setArguments([$transport['dsn'], $transport['options'] + ['transport_name' => $name], new Reference($serializerId)])
2262-
->addTag('messenger.receiver', [
2263-
'alias' => $name,
2264-
'is_failure_transport' => \in_array($name, $failureTransports, true),
2265-
])
2269+
->addTag('messenger.receiver', $tags)
22662270
;
22672271
$container->setDefinition($transportId = 'messenger.transport.'.$name, $transportDefinition);
22682272
$senderAliases[$name] = $transportId;
@@ -2666,7 +2670,6 @@ private function registerMailerConfiguration(array $config, ContainerBuilder $co
26662670
}
26672671
$transports = $config['dsn'] ? ['main' => $config['dsn']] : $config['transports'];
26682672
$container->getDefinition('mailer.transports')->setArgument(0, $transports);
2669-
$container->getDefinition('mailer.default_transport')->setArgument(0, current($transports));
26702673

26712674
$mailer = $container->getDefinition('mailer.mailer');
26722675
if (false === $messageBus = $config['message_bus']) {

Resources/config/mailer.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,7 @@
4646
])
4747

4848
->set('mailer.default_transport', TransportInterface::class)
49-
->factory([service('mailer.transport_factory'), 'fromString'])
50-
->args([
51-
abstract_arg('env(MAILER_DSN)'),
52-
])
49+
->alias('mailer.default_transport', 'mailer.transports')
5350
->alias(TransportInterface::class, 'mailer.default_transport')
5451

5552
->set('mailer.messenger.message_handler', MessageHandler::class)

Tests/DependencyInjection/FrameworkExtensionTestCase.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -2105,8 +2105,7 @@ public function testMailer(string $configFile, array $expectedTransports, array
21052105
$this->assertTrue($container->hasAlias('mailer'));
21062106
$this->assertTrue($container->hasDefinition('mailer.transports'));
21072107
$this->assertSame($expectedTransports, $container->getDefinition('mailer.transports')->getArgument(0));
2108-
$this->assertTrue($container->hasDefinition('mailer.default_transport'));
2109-
$this->assertSame(current($expectedTransports), $container->getDefinition('mailer.default_transport')->getArgument(0));
2108+
$this->assertTrue($container->hasAlias('mailer.default_transport'));
21102109
$this->assertTrue($container->hasDefinition('mailer.envelope_listener'));
21112110
$l = $container->getDefinition('mailer.envelope_listener');
21122111
$this->assertSame('[email protected]', $l->getArgument(0));

0 commit comments

Comments
 (0)