Created
November 25, 2013 13:39
-
-
Save kkasprzak/7641316 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Symfony\Bundle\SwiftmailerBundle\DependencyInjection\Compiler; | |
use Symfony\Component\DependencyInjection\Reference; | |
use Symfony\Component\DependencyInjection\ContainerBuilder; | |
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | |
/** | |
* RegisterPluginsPass registers Swiftmailer plugins. | |
* | |
* @author Fabien Potencier <fabien@symfony.com> | |
*/ | |
class RegisterPluginsPass implements CompilerPassInterface | |
{ | |
public function process(ContainerBuilder $container) | |
{ | |
if (!$container->findDefinition('swiftmailer.mailer') || !$container->getParameter('swiftmailer.mailers')) { | |
return; | |
} | |
$mailers = $container->getParameter('swiftmailer.mailers'); | |
foreach ($mailers as $name => $mailer) { | |
$plugins = $container->findTaggedServiceIds(sprintf('swiftmailer.%s.plugin', $name)); | |
$transport = sprintf('swiftmailer.mailer.%s.transport', $name); | |
$definition = $container->findDefinition($transport); | |
foreach ($plugins as $id => $args) { | |
$definition->addMethodCall('registerPlugin', array(new Reference($id))); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment