LazyResponseEvent.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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\Security\Http\Event;
  11. use Symfony\Component\HttpFoundation\Request;
  12. use Symfony\Component\HttpFoundation\Response;
  13. use Symfony\Component\HttpKernel\Event\RequestEvent;
  14. use Symfony\Component\HttpKernel\HttpKernelInterface;
  15. use Symfony\Component\Security\Core\Exception\LazyResponseException;
  16. /**
  17. * Wraps a lazily computed response in a signaling exception.
  18. *
  19. * @author Nicolas Grekas <p@tchwork.com>
  20. */
  21. final class LazyResponseEvent extends RequestEvent
  22. {
  23. private $event;
  24. public function __construct(parent $event)
  25. {
  26. $this->event = $event;
  27. }
  28. /**
  29. * {@inheritdoc}
  30. */
  31. public function setResponse(Response $response)
  32. {
  33. $this->stopPropagation();
  34. $this->event->stopPropagation();
  35. throw new LazyResponseException($response);
  36. }
  37. /**
  38. * {@inheritdoc}
  39. */
  40. public function getKernel(): HttpKernelInterface
  41. {
  42. return $this->event->getKernel();
  43. }
  44. /**
  45. * {@inheritdoc}
  46. */
  47. public function getRequest(): Request
  48. {
  49. return $this->event->getRequest();
  50. }
  51. /**
  52. * {@inheritdoc}
  53. */
  54. public function getRequestType(): int
  55. {
  56. return $this->event->getRequestType();
  57. }
  58. /**
  59. * {@inheritdoc}
  60. */
  61. public function isMasterRequest(): bool
  62. {
  63. return $this->event->isMasterRequest();
  64. }
  65. }