Permalink
Browse files

Merge pull request #5 from evillemez/container_initialized

Prevent Swfitmailer service from loading on every request
  • Loading branch information...
2 parents 75f8f95 + 3aba074 commit 203e58a237fa04941069ed48009b0e812d5a50f1 @stof stof committed Apr 19, 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 203e58a

Please sign in to comment.