vendor/symfony/symfony/src/Symfony/Component/HttpKernel/EventListener/StreamedResponseListener.php line 30

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Symfony package.
  4.  *
  5.  * (c) Fabien Potencier <fabien@symfony.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Symfony\Component\HttpKernel\EventListener;
  11. use Symfony\Component\HttpFoundation\StreamedResponse;
  12. use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
  13. use Symfony\Component\HttpKernel\KernelEvents;
  14. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  15. /**
  16.  * StreamedResponseListener is responsible for sending the Response
  17.  * to the client.
  18.  *
  19.  * @author Fabien Potencier <fabien@symfony.com>
  20.  */
  21. class StreamedResponseListener implements EventSubscriberInterface
  22. {
  23.     /**
  24.      * Filters the Response.
  25.      */
  26.     public function onKernelResponse(FilterResponseEvent $event)
  27.     {
  28.         if (!$event->isMasterRequest()) {
  29.             return;
  30.         }
  31.         $response $event->getResponse();
  32.         if ($response instanceof StreamedResponse) {
  33.             $response->send();
  34.         }
  35.     }
  36.     public static function getSubscribedEvents()
  37.     {
  38.         return array(
  39.             KernelEvents::RESPONSE => array('onKernelResponse', -1024),
  40.         );
  41.     }
  42. }