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

RejectExplicitFrontControllerRequestsListener.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\HttpKernel\Event\GetResponseEvent;
11 use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
12 use Symfony\Component\HttpKernel\HttpKernelInterface;
13 use Symfony\Component\HttpKernel\KernelEvents;
14
20 class RejectExplicitFrontControllerRequestsListener implements EventSubscriberInterface
21 {
22 public static function getSubscribedEvents()
23 {
24 return [
25 KernelEvents::REQUEST => [
26 ['onKernelRequest', 255],
27 ],
28 ];
29 }
30
34 public function onKernelRequest(GetResponseEvent $event)
35 {
36 if ($event->getRequestType() !== HttpKernelInterface::MASTER_REQUEST) {
37 return;
38 }
39
40 $request = $event->getRequest();
41 $scriptFileName = preg_quote(basename($request->server->get('SCRIPT_FILENAME')), '\\');
42 // This pattern has to match with vhost.template files in meta repository
43 $pattern = sprintf('<^/([^/]+/)?%s([/?#]|$)>', $scriptFileName);
44
45 if (1 === preg_match($pattern, $request->getRequestUri())) {
46 // Trigger generic 404 error to avoid leaking backend technology details.
47 throw new NotFoundHttpException();
48 }
49 }
50 }
eZ\Bundle\EzPublishCoreBundle\EventListener\RejectExplicitFrontControllerRequestsListener
This behavior is reflected in meta repository's vhost.template so it should not be triggered on recom...
Definition: RejectExplicitFrontControllerRequestsListener.php:21
eZ\Bundle\EzPublishCoreBundle\EventListener\RejectExplicitFrontControllerRequestsListener\getSubscribedEvents
static getSubscribedEvents()
Definition: RejectExplicitFrontControllerRequestsListener.php:22
eZ\Bundle\EzPublishCoreBundle\EventListener\RejectExplicitFrontControllerRequestsListener\onKernelRequest
onKernelRequest(GetResponseEvent $event)
Definition: RejectExplicitFrontControllerRequestsListener.php:34
eZ\Bundle\EzPublishCoreBundle\EventListener
Definition: BackgroundIndexingTerminateListener.php:7
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.