我无法将 Doctrine Object 传递给 ORMPaginator 函数这是我的代码的片段
Doctrine\ORM\Tools\Pagination\Paginator as ORMPaginator;..............
if (count($SearchResults) > 0)
{
$ORMPaginator = new ORMPaginator($SearchResults);
}
else
{
$ORMPaginator = new ORMPaginator($VouchersRepo->createQueryBuilder('vouchers'));
}
$Adapter = new DoctrineAdapter($ORMPaginator);
$Paginator = new Paginator($Adapter);
$Paginator->setDefaultItemCountPerPage(5);
$page = (int) $this->params()->fromQuery('page', 1);
$Paginator->setCurrentPageNumber($page);
显然 $ORMPaginator = new ORMPaginator('pass me DQL'); 需要 Query 来生成 Paginator。现在如何将 Doctrine 对象(非 DQL 对象)传递给我无法通过的 ORMPaginator?