Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
S
Silex
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
common
Silex
Commits
8ecc11e6
Commit
8ecc11e6
authored
Mar 26, 2015
by
Dirk Luijk
Committed by
Fabien Potencier
Mar 27, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Flush spool queue for console terminate as well
parent
e12be31a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
2 deletions
+9
-2
src/Silex/Provider/SwiftmailerServiceProvider.php
src/Silex/Provider/SwiftmailerServiceProvider.php
+9
-2
No files found.
src/Silex/Provider/SwiftmailerServiceProvider.php
View file @
8ecc11e6
...
@@ -14,6 +14,7 @@ namespace Silex\Provider;
...
@@ -14,6 +14,7 @@ namespace Silex\Provider;
use
Pimple\Container
;
use
Pimple\Container
;
use
Pimple\ServiceProviderInterface
;
use
Pimple\ServiceProviderInterface
;
use
Silex\Api\EventListenerProviderInterface
;
use
Silex\Api\EventListenerProviderInterface
;
use
Symfony\Component\Console\ConsoleEvents
;
use
Symfony\Component\EventDispatcher\EventDispatcherInterface
;
use
Symfony\Component\EventDispatcher\EventDispatcherInterface
;
use
Symfony\Component\HttpKernel\KernelEvents
;
use
Symfony\Component\HttpKernel\KernelEvents
;
use
Symfony\Component\HttpKernel\Event\PostResponseEvent
;
use
Symfony\Component\HttpKernel\Event\PostResponseEvent
;
...
@@ -92,12 +93,18 @@ class SwiftmailerServiceProvider implements ServiceProviderInterface, EventListe
...
@@ -92,12 +93,18 @@ class SwiftmailerServiceProvider implements ServiceProviderInterface, EventListe
public
function
subscribe
(
Container
$app
,
EventDispatcherInterface
$dispatcher
)
public
function
subscribe
(
Container
$app
,
EventDispatcherInterface
$dispatcher
)
{
{
$
dispatcher
->
addListener
(
KernelEvents
::
TERMINATE
,
function
(
PostResponseEvent
$event
)
use
(
$app
)
{
$
onTerminate
=
function
(
PostResponseEvent
$event
)
use
(
$app
)
{
// To speed things up (by avoiding Swift Mailer initialization), flush
// To speed things up (by avoiding Swift Mailer initialization), flush
// messages only if our mailer has been created (potentially used)
// messages only if our mailer has been created (potentially used)
if
(
$app
[
'mailer.initialized'
])
{
if
(
$app
[
'mailer.initialized'
])
{
$app
[
'swiftmailer.spooltransport'
]
->
getSpool
()
->
flushQueue
(
$app
[
'swiftmailer.transport'
]);
$app
[
'swiftmailer.spooltransport'
]
->
getSpool
()
->
flushQueue
(
$app
[
'swiftmailer.transport'
]);
}
}
});
};
$dispatcher
->
addListener
(
KernelEvents
::
TERMINATE
,
$onTerminate
);
if
(
class_exists
(
'Symfony\Component\Console\ConsoleEvents'
))
{
$dispatcher
->
addListener
(
ConsoleEvents
::
TERMINATE
,
$onTerminate
);
}
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment