src/PHPDish/Bundle/CoreBundle/Service/PaginatorTrait.php
protected function createPaginator(Query $query, $page, $limit = null)
    {
        $paginator = new Pagerfanta(new DoctrineORMAdapter($query));
        $paginator->setCurrentPage($page);
        $paginator->setMaxPerPage($limit ?: $this->getMaxPerPage());

        return $paginator;
    }
protected function createPaginator(Query $query, $page, $limit = null)
    {
        $paginator = new Pagerfanta(new DoctrineORMAdapter($query));
        $paginator->setCurrentPage($page);
        $paginator->setMaxPerPage($limit ?: $this->getMaxPerPage());

        return $paginator;
    }
创建分页.

@param Query    $query
@param int      $page
@param int|null $limit

@return Pagerfanta