Phalcon\Acl\Adapter\Redis::addRole PHP Method

addRole() public method

Example: $acl->addRole(new Phalcon\Acl\Role('administrator'), 'consultor'); $acl->addRole('administrator', 'consultor');
public addRole ( Phalcon\Acl\Role | string $role, string $accessInherits = null ) : boolean
$role Phalcon\Acl\Role | string
$accessInherits string
return boolean
    public function addRole($role, $accessInherits = null)
    {
        if (is_string($role)) {
            $role = new Role($role, ucwords($role) . ' Role');
        }
        if (!$role instanceof RoleInterface) {
            throw new Exception('Role must be either an string or implement RoleInterface');
        }
        $this->redis->hMset('roles', [$role->getName() => $role->getDescription()]);
        $this->redis->sAdd("accessList:{$role}:*:{$this->getDefaultAction()}}", "*");
        if ($accessInherits) {
            $this->addInherit($role->getName(), $accessInherits);
        }
        return true;
    }