|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * This file is part of the Symfony package. |
| 5 | + * |
| 6 | + * (c) Fabien Potencier <fabien@symfony.com> |
| 7 | + * |
| 8 | + * For the full copyright and license information, please view the LICENSE |
| 9 | + * file that was distributed with this source code. |
| 10 | + */ |
| 11 | + |
| 12 | +namespace Symfony\Component\Security\Http\Event; |
| 13 | + |
| 14 | +use Symfony\Component\HttpFoundation\Request; |
| 15 | +use Symfony\Component\HttpFoundation\Response; |
| 16 | +use Symfony\Component\HttpKernel\Event\RequestEvent; |
| 17 | +use Symfony\Component\HttpKernel\HttpKernelInterface; |
| 18 | +use Symfony\Component\Security\Core\Exception\LazyResponseException; |
| 19 | + |
| 20 | +/** |
| 21 | + * Wraps a lazily computed response in a signaling exception. |
| 22 | + * |
| 23 | + * @author Nicolas Grekas <p@tchwork.com> |
| 24 | + */ |
| 25 | +final class LazyResponseEvent extends RequestEvent |
| 26 | +{ |
| 27 | + private $event; |
| 28 | + |
| 29 | + public function __construct(parent $event) |
| 30 | + { |
| 31 | + $this->event = $event; |
| 32 | + } |
| 33 | + |
| 34 | + /** |
| 35 | + * {@inheritdoc} |
| 36 | + */ |
| 37 | + public function setResponse(Response $response) |
| 38 | + { |
| 39 | + $this->stopPropagation(); |
| 40 | + $this->event->stopPropagation(); |
| 41 | + |
| 42 | + throw new LazyResponseException($response); |
| 43 | + } |
| 44 | + |
| 45 | + /** |
| 46 | + * {@inheritdoc} |
| 47 | + */ |
| 48 | + public function getKernel(): HttpKernelInterface |
| 49 | + { |
| 50 | + return $this->event->getKernel(); |
| 51 | + } |
| 52 | + |
| 53 | + /** |
| 54 | + * {@inheritdoc} |
| 55 | + */ |
| 56 | + public function getRequest(): Request |
| 57 | + { |
| 58 | + return $this->event->getRequest(); |
| 59 | + } |
| 60 | + |
| 61 | + /** |
| 62 | + * {@inheritdoc} |
| 63 | + */ |
| 64 | + public function getRequestType(): int |
| 65 | + { |
| 66 | + return $this->event->getRequestType(); |
| 67 | + } |
| 68 | + |
| 69 | + /** |
| 70 | + * {@inheritdoc} |
| 71 | + */ |
| 72 | + public function isMasterRequest(): bool |
| 73 | + { |
| 74 | + return $this->event->isMasterRequest(); |
| 75 | + } |
| 76 | +} |
0 commit comments