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

Commit

Permalink
Merge pull request #5 from evillemez/container_initialized
Browse files Browse the repository at this point in the history
Prevent Swfitmailer service from loading on every request
  • Loading branch information
stof committed Apr 19, 2012
2 parents 75f8f95 + 3aba074 commit 203e58a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions EventListener/EmailSenderListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 203e58a

Please sign in to comment.