Exponential 5.x Kernel 7.5.40 Exponential New Stack (Symfony-based) Kernel — PHP Class Reference

OriginalRequestListener.php
Go to the documentation of this file.
1 <?php
2
7 namespace eZ\Bundle\EzPublishCoreBundle\EventListener;
8
9 use Symfony\Component\EventDispatcher\EventSubscriberInterface;
10 use Symfony\Component\HttpFoundation\Request;
11 use Symfony\Component\HttpKernel\Event\GetResponseEvent;
12 use Symfony\Component\HttpKernel\HttpKernelInterface;
13 use Symfony\Component\HttpKernel\KernelEvents;
14
19 class OriginalRequestListener implements EventSubscriberInterface
20 {
21 public static function getSubscribedEvents()
22 {
23 return [
24 KernelEvents::REQUEST => ['onKernelRequest', 200],
25 ];
26 }
27
28 public function onKernelRequest(GetResponseEvent $event)
29 {
30 if ($event->getRequestType() !== HttpKernelInterface::MASTER_REQUEST) {
31 return;
32 }
33
34 $request = $event->getRequest();
35 if (!$request->headers->has('x-fos-original-url')) {
36 return;
37 }
38
39 $originalRequest = Request::create(
40 $request->getSchemeAndHttpHost() . $request->headers->get('x-fos-original-url'),
41 'GET',
42 [],
43 [],
44 [],
45 ['HTTP_ACCEPT' => $request->headers->get('x-fos-original-accept')]
46 );
47 $originalRequest->headers->set('user-agent', $request->headers->get('user-agent'));
48 $originalRequest->headers->set('accept-language', $request->headers->get('accept-language'));
49 $request->attributes->set('_ez_original_request', $originalRequest);
50 }
51 }
eZ\Bundle\EzPublishCoreBundle\EventListener\OriginalRequestListener
Request listener setting potential original request as current request attribute.
Definition: OriginalRequestListener.php:20
eZ\Bundle\EzPublishCoreBundle\EventListener\OriginalRequestListener\onKernelRequest
onKernelRequest(GetResponseEvent $event)
Definition: OriginalRequestListener.php:28
eZ\Bundle\EzPublishCoreBundle\EventListener\OriginalRequestListener\getSubscribedEvents
static getSubscribedEvents()
Definition: OriginalRequestListener.php:21
eZ\Bundle\EzPublishCoreBundle\EventListener
Definition: BackgroundIndexingTerminateListener.php:7
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.