public function getRecommenders($page = null, $limit = 20) { if (null === $page) { return $this->recommenders; } $paginator = new Pagerfanta(new DoctrineCollectionAdapter($this->recommenders)); $paginator->setMaxPerPage($limit)->setCurrentPage($page); return $paginator->getCurrentPageResults(); }