private function isAllowedRule($rule, $user, $userRoles, $content, $contenttypeSlug, $contentid)
    {
        switch ($rule['type']) {
            case PermissionParser::P_TRUE:
                return true;
            case PermissionParser::P_FALSE:
                return false;
            case PermissionParser::P_SIMPLE:
                return $this->isAllowedSingle($rule['value'], $user, $userRoles, $content, $contenttypeSlug, $contentid);
            case PermissionParser::P_OR:
                foreach ($rule['value'] as $subrule) {
                    if ($this->isAllowedRule($subrule, $user, $userRoles, $content, $contenttypeSlug, $contentid)) {
                        return true;
                    }
                }

                return false;
            case PermissionParser::P_AND:
                foreach ($rule['value'] as $subrule) {
                    if (!$this->isAllowedRule($subrule, $user, $userRoles, $content, $contenttypeSlug, $contentid)) {
                        return false;
                    }
                }

                return true;
            default:
                throw new AccessControlException('Invalid permission check rule of type ' . $rule['type'] . ', expected P_SIMPLE, P_AND or P_OR');
        }
    }
private function isAllowedRule($rule, $user, $userRoles, $content, $contenttypeSlug, $contentid)
    {
        switch ($rule['type']) {
            case PermissionParser::P_TRUE:
                return true;
            case PermissionParser::P_FALSE:
                return false;
            case PermissionParser::P_SIMPLE:
                return $this->isAllowedSingle($rule['value'], $user, $userRoles, $content, $contenttypeSlug, $contentid);
            case PermissionParser::P_OR:
                foreach ($rule['value'] as $subrule) {
                    if ($this->isAllowedRule($subrule, $user, $userRoles, $content, $contenttypeSlug, $contentid)) {
                        return true;
                    }
                }

                return false;
            case PermissionParser::P_AND:
                foreach ($rule['value'] as $subrule) {
                    if (!$this->isAllowedRule($subrule, $user, $userRoles, $content, $contenttypeSlug, $contentid)) {
                        return false;
                    }
                }

                return true;
            default:
                throw new AccessControlException('Invalid permission check rule of type ' . $rule['type'] . ', expected P_SIMPLE, P_AND or P_OR');
        }
    }
private function isAllowedRule ( $ rule , $ user , $ userRoles , $ content , $ contenttypeSlug , $ contentid ) { switch ( $ rule [ 'type' ] ) { case PermissionParser :: P_TRUE : return true ; case PermissionParser :: P_FALSE : return false ; case PermissionParser :: P_SIMPLE : return $ this -> isAllowedSingle ( $ rule [ 'value' ] , $ user , $ userRoles , $ content , $ contenttypeSlug , $ contentid ) ; case PermissionParser :: P_OR : foreach ( $ rule [ 'value' ] as $ subrule ) { if ( $ this -> isAllowedRule ( $ subrule , $ user , $ userRoles , $ content , $ contenttypeSlug , $ contentid ) ) { return true ; } } return false ; case PermissionParser :: P_AND : foreach ( $ rule [ 'value' ] as $ subrule ) { if ( ! $ this -> isAllowedRule ( $ subrule , $ user , $ userRoles , $ content , $ contenttypeSlug , $ contentid ) ) { return false ; } } return true ; default : throw new AccessControlException ( 'Invalid permission check rule of type ' . $ rule [ 'type' ] . ', expected P_SIMPLE, P_AND or P_OR' ) ; } }
Check if a user is allowed a rule 'type'.

@param array                $rule
@param array                $user
@param array                $userRoles
@param string|array|Content $content
@param string               $contenttypeSlug
@param int                  $contentid

@throws AccessControlException

@return bool
Check if a user is allowed a rule type .