vendor/shopware/core/Framework/Routing/RouteParamsCleanupListener.php line 22

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Shopware\Core\Framework\Routing;
  3. use Shopware\Core\PlatformRequest;
  4. use Symfony\Component\HttpKernel\Event\RequestEvent;
  5. /**
  6.  * @package core
  7.  * Remove unwanted information from route_params
  8.  */
  9. class RouteParamsCleanupListener
  10. {
  11.     private const CLEANUP_PARAMETERS = [
  12.         PlatformRequest::ATTRIBUTE_ROUTE_SCOPE,
  13.         PlatformRequest::ATTRIBUTE_CAPTCHA,
  14.         PlatformRequest::ATTRIBUTE_LOGIN_REQUIRED,
  15.         PlatformRequest::ATTRIBUTE_LOGIN_REQUIRED_ALLOW_GUEST,
  16.         PlatformRequest::ATTRIBUTE_ACL,
  17.     ];
  18.     public function __invoke(RequestEvent $event): void
  19.     {
  20.         $routeParams $event->getRequest()->attributes->get('_route_params');
  21.         if ($routeParams) {
  22.             foreach (self::CLEANUP_PARAMETERS as $param) {
  23.                 if (isset($routeParams[$param])) {
  24.                     unset($routeParams[$param]);
  25.                 }
  26.             }
  27.         }
  28.         $event->getRequest()->attributes->set('_route_params'$routeParams);
  29.     }
  30. }