Phalcon\Acl\Factory\Memory::addRole PHP Method

addRole() protected method

Add role to acl.
protected addRole ( string $role, Phalcon\Config $rules )
$role string role
$rules Phalcon\Config rules
    protected function addRole($role, Config $rules)
    {
        // role has inheritance ?
        if ($rules->get('inherit')) {
            // role exists?
            if (!array_key_exists($rules->inherit, $this->roles)) {
                throw new Exception(sprintf('Role "%s" cannot inherit non-existent role "%s".
                     Either such role does not exist or it is set to be inherited before it is actually defined.', $role, $rules->inherit));
            }
            $this->acl->addRole($this->roles[$role], $this->roles[$rules->inherit]);
        } else {
            $this->acl->addRole($this->roles[$role]);
        }
        return $this;
    }