public function getPermissionStatus(string $role, string $permission, string $resource) : bool
    {
        if (!$this->roleRegistry->exists($role)) {
            throw new \Exception(
                sprintf(
                    "The role: %s doesnt exist",
                    (string)$role
                )
            );
        }

        if (!$this->permissionRegistry->exists($permission)) {
            throw new \Exception(
                sprintf(
                    "The permission: %s doesnt exist",
                    (string)$permission
                )
            );
        }

        if (!$this->resourceRegistry->exists($resource)) {
            throw new \Exception(
                sprintf(
                    "The resource: %s doesnt exist",
                    (string)$resource
                )
            );
        }

        $roleObject = $this->globalRegistry->get($role);

        if (isset($roleObject[$resource][$permission]["status"]))
        {
            return $roleObject[$resource][$permission]["status"];
        }

        $parents = $this->roleRegistry->getRegistry()[$role];

        foreach ($parents as $parentRole)
        {
            $permissionStatus = $this->getPermissionStatus($parentRole, $permission, $resource);

            if ($permissionStatus)
            {
                return true;
            }
        }

        return false;
    }
public function getPermissionStatus(string $role, string $permission, string $resource) : bool
    {
        if (!$this->roleRegistry->exists($role)) {
            throw new \Exception(
                sprintf(
                    "The role: %s doesnt exist",
                    (string)$role
                )
            );
        }

        if (!$this->permissionRegistry->exists($permission)) {
            throw new \Exception(
                sprintf(
                    "The permission: %s doesnt exist",
                    (string)$permission
                )
            );
        }

        if (!$this->resourceRegistry->exists($resource)) {
            throw new \Exception(
                sprintf(
                    "The resource: %s doesnt exist",
                    (string)$resource
                )
            );
        }

        $roleObject = $this->globalRegistry->get($role);

        if (isset($roleObject[$resource][$permission]["status"]))
        {
            return $roleObject[$resource][$permission]["status"];
        }

        $parents = $this->roleRegistry->getRegistry()[$role];

        foreach ($parents as $parentRole)
        {
            $permissionStatus = $this->getPermissionStatus($parentRole, $permission, $resource);

            if ($permissionStatus)
            {
                return true;
            }
        }

        return false;
    }
public function getPermissionStatus ( string $ role , string $ permission , string $ resource ) : bool { if ( ! $ this -> roleRegistry -> exists ( $ role ) ) { throw new \ Exception ( sprintf ( "The role: %s doesnt exist" , ( string ) $ role ) ) ; } if ( ! $ this -> permissionRegistry -> exists ( $ permission ) ) { throw new \ Exception ( sprintf ( "The permission: %s doesnt exist" , ( string ) $ permission ) ) ; } if ( ! $ this -> resourceRegistry -> exists ( $ resource ) ) { throw new \ Exception ( sprintf ( "The resource: %s doesnt exist" , ( string ) $ resource ) ) ; } $ roleObject = $ this -> globalRegistry -> get ( $ role ) ; if ( isset ( $ roleObject [ $ resource ] [ $ permission ] [ "status" ] ) ) { return $ roleObject [ $ resource ] [ $ permission ] [ "status" ] ; } $ parents = $ this -> roleRegistry -> getRegistry ( ) [ $ role ] ; foreach ( $ parents as $ parentRole ) { $ permissionStatus = $ this -> getPermissionStatus ( $ parentRole , $ permission , $ resource ) ; if ( $ permissionStatus ) { return true ; } } return false ; }
Retrieve the status of a permission assigned to a role

@param string $role;
@param string $permission
@param string $resource
@return boolean
Retrieve the status of a permission assigned to a role