Commit 27eb5267 authored by Fabien Potencier's avatar Fabien Potencier

moved Swiftmailer finish call to a proper listener

parent 7bee6bfd
......@@ -13,13 +13,17 @@ namespace Silex\Provider;
use Silex\Application;
use Silex\ServiceProviderInterface;
use Silex\EventListenerProviderInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Event\PostResponseEvent;
/**
* Swiftmailer Provider.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class SwiftmailerServiceProvider implements ServiceProviderInterface
class SwiftmailerServiceProvider implements ServiceProviderInterface, EventListenerProviderInterface
{
public function register(Application $app)
{
......@@ -84,9 +88,9 @@ class SwiftmailerServiceProvider implements ServiceProviderInterface
});
}
public function boot(Application $app)
public function subscribe(Application $app, EventDispatcherInterface $dispatcher)
{
$app->finish(function () use ($app) {
$dispatcher->addListener(KernelEvents::TERMINATE, function (PostResponseEvent $event) use ($app) {
// To speed things up (by avoiding Swift Mailer initialization), flush
// messages only if our mailer has been created (potentially used)
if ($app['mailer.initialized']) {
......@@ -94,4 +98,8 @@ class SwiftmailerServiceProvider implements ServiceProviderInterface
}
});
}
public function boot(Application $app)
{
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment