/** * * @param Post $post * @param int $limit * @param int $limit * @return array */ public function related(Post $post, $limit = 3) { $this->sphinx->SetMatchMode(SPH_MATCH_ANY); $this->sphinx->SetLimits(0, $limit); $ids = $this->sphinxSearch($post->getTagsAsString()); if (!$ids) { return array(); } $items = $this->em->getRepository('BlogBundle:Post')->getByIds($ids); $this->items = $this->orderResults($ids, $items); return $this->items; }