src/wbx/UserBundle/Controller/BaseController.php line 48

Open in your IDE?
  1. <?php
  2. namespace wbx\UserBundle\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\Request;
  5. class BaseController extends AbstractController
  6. {
  7.     protected function getGrantedRoles(): array
  8.     {
  9.         $roles = [
  10.             'ROLE_SUPER_ADMIN',
  11.             'ROLE_ADMIN',
  12.             'ROLE_EMPLOYE',
  13.             'ROLE_DIRECTION',
  14.             'ROLE_AGENT_ADMINISTRATIF',
  15.             'ROLE_METREUR',
  16.             'ROLE_RESPONSABLE_COMMERCIAL',
  17.             'ROLE_RESPONSABLE_TECHNIQUE',
  18.             'ROLE_COMMERCIAL',
  19.             'ROLE_AGENT_TECHNIQUE',
  20.             'ROLE_SOUS_TRAITANT',
  21.             'ROLE_FOURNISSEUR',
  22.             'ROLE_CLIENT',
  23.             'ROLE_PROSPECT',
  24.             'ROLE_COMPTABLE',
  25.             'ROLE_TRAFFIC_MANAGER',
  26.             'ROLE_SUPERVISEUR',
  27.             'ROLE_RESPONSABLE_CALL',
  28.             'ROLE_TELEPROSPECTEUR',
  29.         ];
  30.         $granted = [];
  31.         foreach ($roles as $role) {
  32.             if ($this->get('security.authorization_checker')->isGranted($role)) {
  33.                 $granted[] = $role;
  34.             }
  35.         }
  36.         return $granted;
  37.     }
  38.     protected function isModal(Request $request): bool
  39.     {
  40.         $modal false;
  41.         $target_path $request->getSession()->get('_security.secured.target_path');
  42.         if ($target_path != '') {
  43.             $paths parse_url((string) $target_path);
  44.             $path $paths['path'].($paths['query'] ?? '');
  45.             $path str_replace('app_dev.php/'''$path);
  46.             $route $this->get('router')->match($path);
  47.             $modal = isset($route['modal']) && $route['modal'] == '1';
  48.         }
  49.         return $modal;
  50.     }
  51. }