request->getQuery('limit', 'int', 5); $article = $this->checkArticle($id); if (empty($article->tags)) return []; $tagIds = kg_array_column($article->tags, 'id'); $tagId = kg_array_rand($tagIds); $cache = new TaggedArticleListCache(); $articles = $cache->get($tagId); if (empty($articles)) return []; foreach ($articles as $key => $article) { if ($article['id'] == $id) { unset($articles[$key]); } } if ($limit < count($articles)) { $articles = array_slice($articles, $limit); } return $articles; } }