<?php


namespace Lc\SovBundle\Definition;


class RolesDefinition implements RolesDefinitionInterface
{
    const ROLE_USER = 'ROLE_USER' ;
    const ROLE_ADMIN = 'ROLE_ADMIN' ;
    const ROLE_SUPER_ADMIN = 'ROLE_SUPER_ADMIN' ;

    protected $roles = array(
            self::ROLE_USER => [
                    'label' => 'Utilisateurs',
                    'role' => self::ROLE_USER,
            ],
            self::ROLE_ADMIN => [
                    'label' => 'Administrateurs',
                    'role' => self::ROLE_ADMIN,
            ],
            self::ROLE_SUPER_ADMIN => [
                    'label' => 'SuperAdmin',
                    'role' => self::ROLE_SUPER_ADMIN,
            ],
    );

    public function getRoles(): array
    {
        return $this->roles;
    }

    public function getRole($role): ?array
    {
        if (isset($this->roles[$role])) {
            return $this->roles[$role];
        } else {
            return null;
        }
    }

    public function getRolesList(): array
    {
        $rolesList = array();
        foreach ($this->roles as $role) {
            $rolesList[$role['label']] = $role['role'];
        }

        return $rolesList;
    }
}