Skip to content

Commit 611f821

Browse files
committed
Fixed BC break in AdDSwiftMailerTransportPass
1 parent 78883d8 commit 611f821

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

DependencyInjection/Compiler/AddSwiftMailerTransportPass.php

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
class AddSwiftMailerTransportPass implements CompilerPassInterface
2525
{
2626
/**
27-
* {@inheritDoc}
27+
* {@inheritdoc}
2828
*/
2929
public function process(ContainerBuilder $container)
3030
{
@@ -34,22 +34,23 @@ public function process(ContainerBuilder $container)
3434
$definition = $container->getDefinition($id);
3535
$mailerId = (string) $definition->getArgument(0);
3636

37-
if (
38-
$container->hasAlias($mailerId . '.transport.real') ||
39-
$container->hasDefinition($mailerId . '.transport.real')
40-
) {
41-
$definition->addMethodCall(
42-
'setTransport',
43-
array(new Reference($mailerId . '.transport.real'))
44-
);
45-
} elseif (
46-
$container->hasAlias($mailerId . '.transport') ||
47-
$container->hasDefinition($mailerId . '.transport')
48-
) {
49-
$definition->addMethodCall(
50-
'setTransport',
51-
array(new Reference($mailerId . '.transport'))
52-
);
37+
// Try to fetch the transport for a non-default mailer first, then go with the default swiftmailer
38+
$possibleServices = array(
39+
$mailerId.'.transport.real',
40+
$mailerId.'.transport',
41+
'swiftmailer.transport.real',
42+
'swiftmailer.transport',
43+
);
44+
45+
foreach ($possibleServices as $serviceId) {
46+
if ($container->hasAlias($serviceId) || $container->hasDefinition($serviceId)) {
47+
$definition->addMethodCall(
48+
'setTransport',
49+
array(new Reference($serviceId))
50+
);
51+
52+
break;
53+
}
5354
}
5455
}
5556
}

0 commit comments

Comments
 (0)