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

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