src/Subscriber/AsyncListener.php line 24

Open in your IDE?
  1. <?php
  2. namespace App\Subscriber;
  3. use Symfony\Component\HttpKernel\Event\TerminateEvent;
  4. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  5. use App\Response\AsyncResponse;
  6. /**
  7.  * Class AsyncListener
  8.  */
  9. class AsyncListener implements EventSubscriberInterface
  10. {
  11.     public static function getSubscribedEvents()
  12.     {
  13.         return array(
  14.             'kernel.terminate' => 'onTerminate'
  15.         );
  16.     }
  17.     public function onTerminate(TerminateEvent $event)
  18.     {
  19.         //Run this stuff before the terminate events
  20.         $response $event->getResponse();
  21.         if ($response instanceof AsyncResponse) {
  22.             $response->callTerminateCallback();
  23.         }
  24.     }
  25. }