| Total Complexity | 4 |
| Total Lines | 31 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | class PermissionHelper |
||
| 13 | { |
||
| 14 | public function __construct( |
||
| 15 | private ParameterBagInterface $parameterBag, |
||
| 16 | private PermissionRelRoleRepository $permissionRelRoleRepository |
||
| 17 | ) {} |
||
| 18 | |||
| 19 | public function getUserRoles(): array |
||
| 20 | { |
||
| 21 | $roles = $this->parameterBag->get('security.role_hierarchy.roles'); |
||
| 22 | |||
| 23 | return array_filter(array_keys($roles), function ($role) { |
||
| 24 | return !str_starts_with($role, 'ROLE_CURRENT_') && 'ROLE_ANONYMOUS' !== $role; |
||
| 25 | }); |
||
| 26 | } |
||
| 27 | |||
| 28 | public function hasPermission(string $permissionSlug, array $roles): bool |
||
| 43 | } |
||
| 44 | } |
||
| 45 |