You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.2 KiB

3 years ago
  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\Response;
  12. /**
  13. * Allows to create a response for a request.
  14. *
  15. * Call setResponse() to set the response that will be returned for the
  16. * current request. The propagation of this event is stopped as soon as a
  17. * response is set.
  18. *
  19. * @author Bernhard Schussek <bschussek@gmail.com>
  20. */
  21. class RequestEvent extends KernelEvent
  22. {
  23. private $response;
  24. /**
  25. * Returns the response object.
  26. *
  27. * @return Response|null
  28. */
  29. public function getResponse()
  30. {
  31. return $this->response;
  32. }
  33. /**
  34. * Sets a response and stops event propagation.
  35. */
  36. public function setResponse(Response $response)
  37. {
  38. $this->response = $response;
  39. $this->stopPropagation();
  40. }
  41. /**
  42. * Returns whether a response was set.
  43. *
  44. * @return bool Whether a response was set
  45. */
  46. public function hasResponse()
  47. {
  48. return null !== $this->response;
  49. }
  50. }