checkCategoryCache($id); if (!$category) { throw new BadRequestException('article_query.invalid_category'); } if ($category->type != CategoryModel::TYPE_ARTICLE) { throw new BadRequestException('article_query.invalid_category'); } return $category; } public function checkTag($id) { $validator = new Tag(); $tag = $validator->checkTagCache($id); if (!$tag) { throw new BadRequestException('article_query.invalid_tag'); } return $tag; } public function checkSort($sort) { $types = ArticleModel::sortTypes(); if (!isset($types[$sort])) { throw new BadRequestException('article_query.invalid_sort'); } return $sort; } }