vendor/contao/core-bundle/src/Routing/ScopeMatcher.php line 76

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4.  * This file is part of Contao.
  5.  *
  6.  * (c) Leo Feyer
  7.  *
  8.  * @license LGPL-3.0-or-later
  9.  */
  10. namespace Contao\CoreBundle\Routing;
  11. use Symfony\Component\HttpFoundation\Request;
  12. use Symfony\Component\HttpFoundation\RequestMatcherInterface;
  13. use Symfony\Component\HttpKernel\Event\KernelEvent;
  14. class ScopeMatcher
  15. {
  16.     private RequestMatcherInterface $backendMatcher;
  17.     private RequestMatcherInterface $frontendMatcher;
  18.     /**
  19.      * @internal
  20.      */
  21.     public function __construct(RequestMatcherInterface $backendMatcherRequestMatcherInterface $frontendMatcher)
  22.     {
  23.         $this->backendMatcher $backendMatcher;
  24.         $this->frontendMatcher $frontendMatcher;
  25.     }
  26.     public function isContaoMainRequest(KernelEvent $event): bool
  27.     {
  28.         return $event->isMainRequest() && $this->isContaoRequest($event->getRequest());
  29.     }
  30.     /**
  31.      * @deprecated Deprecated since Contao 4.13, to be removed in Contao 5.0; use
  32.      *             ScopeMatcher::isContaoMainRequest() instead
  33.      */
  34.     public function isContaoMasterRequest(KernelEvent $event): bool
  35.     {
  36.         trigger_deprecation('contao/core-bundle''4.13''Using ScopeMatcher::isContaoMasterRequest() has been deprecated and will no longer work in Contao 5.0. Use ScopeMatcher::isContaoMainRequest() instead.');
  37.         return $this->isContaoMainRequest($event);
  38.     }
  39.     public function isBackendMainRequest(KernelEvent $event): bool
  40.     {
  41.         return $event->isMainRequest() && $this->isBackendRequest($event->getRequest());
  42.     }
  43.     /**
  44.      * @deprecated Deprecated since Contao 4.13, to be removed in Contao 5.0; use
  45.      *             ScopeMatcher::isBackendMainRequest() instead
  46.      */
  47.     public function isBackendMasterRequest(KernelEvent $event): bool
  48.     {
  49.         trigger_deprecation('contao/core-bundle''4.13''Using ScopeMatcher::isBackendMasterRequest() has been deprecated and will no longer work in Contao 5.0. Use ScopeMatcher::isBackendMainRequest() instead.');
  50.         return $this->isBackendMainRequest($event);
  51.     }
  52.     public function isFrontendMainRequest(KernelEvent $event): bool
  53.     {
  54.         return $event->isMainRequest() && $this->isFrontendRequest($event->getRequest());
  55.     }
  56.     /**
  57.      * @deprecated Deprecated since Contao 4.13, to be removed in Contao 5.0; use
  58.      *             ScopeMatcher::isFrontendMainRequest() instead
  59.      */
  60.     public function isFrontendMasterRequest(KernelEvent $event): bool
  61.     {
  62.         trigger_deprecation('contao/core-bundle''4.13''Using ScopeMatcher::isFrontendMasterRequest() has been deprecated and will no longer work in Contao 5.0. Use ScopeMatcher::isFrontendMainRequest() instead.');
  63.         return $this->isFrontendMainRequest($event);
  64.     }
  65.     public function isContaoRequest(Request $request): bool
  66.     {
  67.         return $this->isBackendRequest($request) || $this->isFrontendRequest($request);
  68.     }
  69.     public function isBackendRequest(Request $request): bool
  70.     {
  71.         return $this->backendMatcher->matches($request);
  72.     }
  73.     public function isFrontendRequest(Request $request): bool
  74.     {
  75.         return $this->frontendMatcher->matches($request);
  76.     }
  77. }