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');
        }
    }