<?php
namespace App\Subscriber;
use Symfony\Component\HttpKernel\Event\TerminateEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use App\Response\AsyncResponse;
/**
* Class AsyncListener
*/
class AsyncListener implements EventSubscriberInterface
{
public static function getSubscribedEvents()
{
return array(
'kernel.terminate' => 'onTerminate'
);
}
public function onTerminate(TerminateEvent $event)
{
//Run this stuff before the terminate events
$response = $event->getResponse();
if ($response instanceof AsyncResponse) {
$response->callTerminateCallback();
}
}
}