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

Commit 9c76b12

Browse files
committed
bug #64 Flush spool queue for console terminate as well (BitOne)
This PR was merged into the master branch. Discussion ---------- Flush spool queue for console terminate as well Mail spool were only flush at the end of a HTTP Request (KernelEvents:TERMINATE). In case of a console command sending mail using a spool, the spool was not flushed, so no mail was sent (and in case of MemorySpool, the mail were lost). So this PR subscribes to the ConsoleEvents:TERMINATE to do the same flushing as in the context of a HTTP request. Commits ------- 4de0f63 Cleanup use and unused parameter 4b90392 Flush spool queue for console terminate as well 1c87809 Merge pull request #61 from ruian/patch-1 336d332 Remove redondant parameter
2 parents 0ec5676 + 4de0f63 commit 9c76b12

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

EventListener/EmailSenderListener.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414
use Symfony\Component\DependencyInjection\ContainerInterface;
1515
use Symfony\Component\DependencyInjection\IntrospectableContainerInterface;
16-
use Symfony\Component\HttpKernel\Event\PostResponseEvent;
1716
use Symfony\Component\HttpKernel\KernelEvents;
17+
use Symfony\Component\Console\ConsoleEvents;
1818
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
1919

2020
/**
@@ -33,7 +33,7 @@ public function __construct(ContainerInterface $container)
3333
$this->container = $container;
3434
}
3535

36-
public function onKernelTerminate(PostResponseEvent $event)
36+
public function onTerminate()
3737
{
3838
if (!$this->container->has('mailer')) {
3939
return;
@@ -57,6 +57,9 @@ public function onKernelTerminate(PostResponseEvent $event)
5757

5858
static public function getSubscribedEvents()
5959
{
60-
return array(KernelEvents::TERMINATE => 'onKernelTerminate');
60+
return array(
61+
KernelEvents::TERMINATE => 'onTerminate',
62+
ConsoleEvents::TERMINATE => 'onTerminate'
63+
);
6164
}
6265
}

Resources/config/swiftmailer.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
<parameter key="swiftmailer.transport.smtp.class">Swift_Transport_EsmtpTransport</parameter>
2121

22-
<parameter key="swiftmailer.plugin.redirecting.class">Swift_Plugins_RedirectingPlugin</parameter>
2322
<parameter key="swiftmailer.plugin.blackhole.class">Swift_Plugins_BlackholePlugin</parameter>
2423

2524
<parameter key="swiftmailer.spool.file.class">Swift_FileSpool</parameter>

0 commit comments

Comments
 (0)