<?php
namespace wbx\UserBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
class BaseController extends AbstractController
{
protected function getGrantedRoles(): array
{
$roles = [
'ROLE_SUPER_ADMIN',
'ROLE_ADMIN',
'ROLE_EMPLOYE',
'ROLE_DIRECTION',
'ROLE_AGENT_ADMINISTRATIF',
'ROLE_METREUR',
'ROLE_RESPONSABLE_COMMERCIAL',
'ROLE_RESPONSABLE_TECHNIQUE',
'ROLE_COMMERCIAL',
'ROLE_AGENT_TECHNIQUE',
'ROLE_SOUS_TRAITANT',
'ROLE_FOURNISSEUR',
'ROLE_CLIENT',
'ROLE_PROSPECT',
'ROLE_COMPTABLE',
'ROLE_TRAFFIC_MANAGER',
'ROLE_SUPERVISEUR',
'ROLE_RESPONSABLE_CALL',
'ROLE_TELEPROSPECTEUR',
];
$granted = [];
foreach ($roles as $role) {
if ($this->get('security.authorization_checker')->isGranted($role)) {
$granted[] = $role;
}
}
return $granted;
}
protected function isModal(Request $request): bool
{
$modal = false;
$target_path = $request->getSession()->get('_security.secured.target_path');
if ($target_path != '') {
$paths = parse_url((string) $target_path);
$path = $paths['path'].($paths['query'] ?? '');
$path = str_replace('app_dev.php/', '', $path);
$route = $this->get('router')->match($path);
$modal = isset($route['modal']) && $route['modal'] == '1';
}
return $modal;
}
}