You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 line
1.0KB

  1. <?php
  2. namespace Lc\SovBundle\Definition;
  3. class RolesDefinition implements RolesDefinitionInterface
  4. {
  5. protected $roles = array(
  6. 'ROLE_USER' => [
  7. 'label' => 'Utilisateurs',
  8. 'role' => 'ROLE_USER',
  9. ],
  10. 'ROLE_ADMIN' => [
  11. 'label' => 'Administrateurs',
  12. 'role' => 'ROLE_ADMIN',
  13. ],
  14. 'ROLE_SUPER_ADMIN' => [
  15. 'label' => 'SuperAdmin',
  16. 'role' => 'ROLE_SUPER_ADMIN',
  17. ],
  18. );
  19. public function getRoles(): array
  20. {
  21. return $this->roles;
  22. }
  23. public function getRole($role): ?array
  24. {
  25. if (isset($this->roles[$role])) {
  26. return $this->roles[$role];
  27. } else {
  28. return null;
  29. }
  30. }
  31. public function getRolesList(): array
  32. {
  33. $rolesList = array();
  34. foreach ($this->roles as $role) {
  35. $rolesList[$role['label']] = $role['role'];
  36. }
  37. return $rolesList;
  38. }
  39. }