Skip to content
This repository was archived by the owner on Feb 6, 2022. It is now read-only.

Commit a060505

Browse files
committed
skip if DI is not in 3.2
1 parent a70cf54 commit a060505

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

DependencyInjection/SwiftmailerExtension.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,17 @@ protected function configureMailer($name, array $mailer, ContainerBuilder $conta
7272
->setDefinition(sprintf('swiftmailer.mailer.%s.transport.eventdispatcher', $name), $definitionDecorator)
7373
;
7474

75-
$options = array();
76-
$envVariablesAllowed = array('transport', 'url', 'username', 'password', 'host', 'port', 'timeout', 'source_ip', 'local_domain', 'encryption', 'auth_mode');
77-
foreach ($envVariablesAllowed as $key) {
78-
$container->resolveEnvPlaceholders($mailer[$key], null, $userEnvs);
79-
$options[$key] = $mailer[$key];
75+
if (method_exists($container, 'resolveEnvPlaceholders')) {
76+
$options = array();
77+
$envVariablesAllowed = array('transport', 'url', 'username', 'password', 'host', 'port', 'timeout', 'source_ip', 'local_domain', 'encryption', 'auth_mode');
78+
foreach ($envVariablesAllowed as $key) {
79+
$container->resolveEnvPlaceholders($mailer[$key], null, $usedEnvs);
80+
$options[$key] = $mailer[$key];
81+
}
82+
} else {
83+
$usedEnvs = false;
8084
}
81-
82-
if ($userEnvs) {
85+
if ($usedEnvs) {
8386
$transportId = sprintf('swiftmailer.mailer.%s.transport.dynamic', $name);
8487
$definitionDecorator = new Definition('\Swift_Transport');
8588
$definitionDecorator->setFactory(array('\Symfony\Bundle\SwiftmailerBundle\DependencyInjection\SwiftmailerTransportFactory', 'createTransport'));

0 commit comments

Comments
 (0)