ResponseEvent.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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\Event;
  11. use Symfony\Component\HttpFoundation\Request;
  12. use Symfony\Component\HttpFoundation\Response;
  13. use Symfony\Component\HttpKernel\HttpKernelInterface;
  14. /**
  15. * Allows to filter a Response object.
  16. *
  17. * You can call getResponse() to retrieve the current response. With
  18. * setResponse() you can set a new response that will be returned to the
  19. * browser.
  20. *
  21. * @author Bernhard Schussek <bschussek@gmail.com>
  22. */
  23. final class ResponseEvent extends KernelEvent
  24. {
  25. private $response;
  26. public function __construct(HttpKernelInterface $kernel, Request $request, int $requestType, Response $response)
  27. {
  28. parent::__construct($kernel, $request, $requestType);
  29. $this->setResponse($response);
  30. }
  31. public function getResponse(): Response
  32. {
  33. return $this->response;
  34. }
  35. public function setResponse(Response $response): void
  36. {
  37. $this->response = $response;
  38. }
  39. }