vendor/symfony/http-kernel/EventListener/StreamedResponseListener.php line 32

  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\EventDispatcher\EventSubscriberInterface;
  12. use Symfony\Component\HttpFoundation\StreamedResponse;
  13. use Symfony\Component\HttpKernel\Event\ResponseEvent;
  14. use Symfony\Component\HttpKernel\KernelEvents;
  15. trigger_deprecation('symfony/http-kernel''6.1''The "%s" class is deprecated.'StreamedResponseListener::class);
  16. /**
  17.  * StreamedResponseListener is responsible for sending the Response
  18.  * to the client.
  19.  *
  20.  * @author Fabien Potencier <fabien@symfony.com>
  21.  *
  22.  * @final
  23.  *
  24.  * @deprecated since Symfony 6.1
  25.  */
  26. class StreamedResponseListener implements EventSubscriberInterface
  27. {
  28.     /**
  29.      * Filters the Response.
  30.      */
  31.     public function onKernelResponse(ResponseEvent $event): void
  32.     {
  33.         if (!$event->isMainRequest()) {
  34.             return;
  35.         }
  36.         $response $event->getResponse();
  37.         if ($response instanceof StreamedResponse) {
  38.             $response->send();
  39.         }
  40.     }
  41.     public static function getSubscribedEvents(): array
  42.     {
  43.         return [
  44.             KernelEvents::RESPONSE => ['onKernelResponse', -1024],
  45.         ];
  46.     }
  47. }