src/Controller/BaseController.php line 25

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Security\SecurityConstants;
  4. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  5. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  6. use Symfony\Component\Security\Core\Security;
  7. class BaseController extends AbstractController
  8. {
  9.     public const PARAM_ADMIN_URL 'admin_url';
  10.     protected Security $security;
  11.     public function __construct(Security $security){
  12.         $this->security $security;
  13.     }
  14.     /**
  15.      * @param SessionInterface $session
  16.      * @return bool
  17.      */
  18.     protected function includeInactive(SessionInterface $session)
  19.     {
  20.         $isPreviewMode $session->get('mode') === 'preview-mode';
  21.         $isPreviewer $this->security->isGranted(SecurityConstants::ROLE_PREVIEWER);
  22.         $includeInactive $isPreviewer && $isPreviewMode;
  23.         return $includeInactive;
  24.     }
  25. }