| @@ 23-57 (lines=35) @@ | ||
| 20 | /** |
|
| 21 | * Adds request ID on requests. |
|
| 22 | */ |
|
| 23 | final class AddsRequestIdOnRequest implements EventSubscriberInterface |
|
| 24 | { |
|
| 25 | /** |
|
| 26 | * @var RequestDecorator |
|
| 27 | */ |
|
| 28 | private $decorator; |
|
| 29 | ||
| 30 | /** |
|
| 31 | * @param RequestDecorator $decorator |
|
| 32 | */ |
|
| 33 | public function __construct(RequestDecorator $decorator) |
|
| 34 | { |
|
| 35 | $this->decorator = $decorator; |
|
| 36 | } |
|
| 37 | ||
| 38 | /** |
|
| 39 | * @param GetResponseEvent $event |
|
| 40 | */ |
|
| 41 | public function onRequest(GetResponseEvent $event) |
|
| 42 | { |
|
| 43 | if (!$event->getRequestType() === HttpKernelInterface::MASTER_REQUEST) { |
|
| 44 | return; |
|
| 45 | } |
|
| 46 | ||
| 47 | $this->decorator->decorateRequest($event->getRequest()); |
|
| 48 | } |
|
| 49 | ||
| 50 | /** |
|
| 51 | * {@inheritdoc} |
|
| 52 | */ |
|
| 53 | public static function getSubscribedEvents() |
|
| 54 | { |
|
| 55 | return [KernelEvents::REQUEST => ['onRequest', 200]]; |
|
| 56 | } |
|
| 57 | } |
|
| 58 | ||
| @@ 23-57 (lines=35) @@ | ||
| 20 | /** |
|
| 21 | * Adds request ID on responses. |
|
| 22 | */ |
|
| 23 | final class AddsRequestIdOnResponse implements EventSubscriberInterface |
|
| 24 | { |
|
| 25 | /** |
|
| 26 | * @var ResponseDecorator |
|
| 27 | */ |
|
| 28 | private $decorator; |
|
| 29 | ||
| 30 | /** |
|
| 31 | * @param ResponseDecorator $decorator |
|
| 32 | */ |
|
| 33 | public function __construct(ResponseDecorator $decorator) |
|
| 34 | { |
|
| 35 | $this->decorator = $decorator; |
|
| 36 | } |
|
| 37 | ||
| 38 | /** |
|
| 39 | * @param FilterResponseEvent $event |
|
| 40 | */ |
|
| 41 | public function onResponse(FilterResponseEvent $event) |
|
| 42 | { |
|
| 43 | if (!$event->getRequestType() === HttpKernelInterface::MASTER_REQUEST) { |
|
| 44 | return; |
|
| 45 | } |
|
| 46 | ||
| 47 | $this->decorator->decorateResponse($event->getResponse()); |
|
| 48 | } |
|
| 49 | ||
| 50 | /** |
|
| 51 | * {@inheritdoc} |
|
| 52 | */ |
|
| 53 | public static function getSubscribedEvents() |
|
| 54 | { |
|
| 55 | return [KernelEvents::RESPONSE => ['onResponse', -200]]; |
|
| 56 | } |
|
| 57 | } |
|
| 58 | ||