Permalink
Browse files

implemented IntrospectableContainerInterface::initialized() in EmailS…

…enderListener to prevent the mailer service from loading on every request
  • Loading branch information...
1 parent 75f8f95 commit 3aba074e3039cc17c778b55183577c09a5268f14 @evillemez evillemez committed with Evan Villemez Apr 15, 2012
Showing with 5 additions and 0 deletions.
  1. +5 −0 EventListener/EmailSenderListener.php
@@ -12,6 +12,7 @@
namespace Symfony\Bundle\SwiftmailerBundle\EventListener;
use Symfony\Component\DependencyInjection\ContainerInterface;
+use Symfony\Component\DependencyInjection\IntrospectableContainerInterface;
use Symfony\Component\HttpKernel\Event\PostResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
@@ -34,6 +35,10 @@ public function __construct(ContainerInterface $container, $autoStart = false)
public function onKernelTerminate(PostResponseEvent $event)
{
+ if ($container instanceof IntrospectableContainerInterface && !$container->initialized('mailer')) {
+ return;
+ }
+
$transport = $this->container->get('mailer')->getTransport();
if (!$transport instanceof \Swift_Transport_SpoolTransport) {
return;

0 comments on commit 3aba074

Please sign in to comment.