Skip to content

Commit

Permalink
Merge pull request #140 from Nyholm/bcBreak
Browse files Browse the repository at this point in the history
Fixed BC break in AdDSwiftMailerTransportPass
  • Loading branch information
Seldaek committed Oct 2, 2015
2 parents 78883d8 + 611f821 commit 7117b9a
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions DependencyInjection/Compiler/AddSwiftMailerTransportPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
class AddSwiftMailerTransportPass implements CompilerPassInterface
{
/**
* {@inheritDoc}
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
{
Expand All @@ -34,22 +34,23 @@ public function process(ContainerBuilder $container)
$definition = $container->getDefinition($id);
$mailerId = (string) $definition->getArgument(0);

if (
$container->hasAlias($mailerId . '.transport.real') ||
$container->hasDefinition($mailerId . '.transport.real')
) {
$definition->addMethodCall(
'setTransport',
array(new Reference($mailerId . '.transport.real'))
);
} elseif (
$container->hasAlias($mailerId . '.transport') ||
$container->hasDefinition($mailerId . '.transport')
) {
$definition->addMethodCall(
'setTransport',
array(new Reference($mailerId . '.transport'))
);
// Try to fetch the transport for a non-default mailer first, then go with the default swiftmailer
$possibleServices = array(
$mailerId.'.transport.real',
$mailerId.'.transport',
'swiftmailer.transport.real',
'swiftmailer.transport',
);

foreach ($possibleServices as $serviceId) {
if ($container->hasAlias($serviceId) || $container->hasDefinition($serviceId)) {
$definition->addMethodCall(
'setTransport',
array(new Reference($serviceId))
);

break;
}
}
}
}
Expand Down

0 comments on commit 7117b9a

Please sign in to comment.