vendor/sulu/sulu/src/Sulu/Bundle/SecurityBundle/EventListener/SystemListener.php line 54

  1.  * (c) Sulu GmbH
  2.  *
  3.  * This source file is subject to the MIT license that is bundled
  4.  * with this source code in the file LICENSE.
  5.  */
  6. namespace Sulu\Bundle\SecurityBundle\EventListener;
  7. use Sulu\Bundle\AdminBundle\Admin\Admin;
  8. use Sulu\Bundle\SecurityBundle\System\SystemStoreInterface;
  9. use Sulu\Component\DocumentManager\Subscriber\EventSubscriberInterface;
  10. use Sulu\Component\HttpKernel\SuluKernel;
  11. use Sulu\Component\Webspace\Analyzer\RequestAnalyzerInterface;
  12. use Symfony\Component\HttpKernel\Event\RequestEvent;
  13. use Symfony\Component\HttpKernel\KernelEvents;
  14. class SystemListener implements EventSubscriberInterface
  15. {
  16.     public function __construct(
  17.         private SystemStoreInterface $systemStore,
  18.         private ?RequestAnalyzerInterface $requestAnalyzer,
  19.         private string $context
  20.     ) {
  21.         if (null !== $requestAnalyzer) {
  22.             @trigger_deprecation('sulu/sulu''2.4''The argument "%s" in class "%s" is deprecated and not longer required set `null` instead.'RequestAnalyzerInterface::class, __CLASS__);
  23.         }
  24.     }
  25.     public static function getSubscribedEvents(): array
  26.     {
  27.         return [KernelEvents::REQUEST => ['onKernelRequest'24]];
  28.     }
  29.     public function onKernelRequest(RequestEvent $requestEvent)
  30.     {
  31.         if (SuluKernel::CONTEXT_ADMIN === $this->context) {
  32.             $this->systemStore->setSystem(Admin::SULU_ADMIN_SECURITY_SYSTEM);
  33.             return;
  34.         }
  35.     }
  36. }