我正在尝试将允许对实体列表进行分页的KnpPaginatorBundle集成到我的 Symfony 项目中。
所以我按照自述文件的说明像往常一样安装和设置捆绑包。
但是,当我测试 KnpPaginatorBundle 示例的实现(复制过去的实现)时,我收到以下错误:
Fatal error: Class Knp\Component\Pager\Event\Subscriber\Paginate\Doctrine\ORM\Query\AsIsHydrator contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Doctrine\ORM\Internal\Hydration\AbstractHydrator::_hydrateAll) in D:\workspace\wedding\vendor\knp-components\src\Knp\Component\Pager\Event\Subscriber\Paginate\Doctrine\ORM\Query\AsIsHydrator.php on line 13
我在 Google 上没有找到任何解决方案:-/
欢迎任何帮助...谢谢
我的控制器:
/**
* @Route("/pagin", name="pagin")
* @Template()
*/
public function paginAction(){
$em = $this->get('doctrine.orm.entity_manager');
$dql = "SELECT c FROM LgpWeddingBundle:Contact c";
$query = $em->createQuery($dql);
$paginator = $this->get('knp_paginator');
$pagination = $paginator->paginate(
$query,
$this->get('request')->query->get('page', 1)/*page number*/,
10/*limit per page*/
);
// parameters to template
// return $this->render('LgpWeddingBundle:Contact:pagin.html.twig', array('pagination' => $pagination));
return array('pagination' => $pagination);
}
Knp\Component\Pager\Event\Subscriber\Paginate\Doctrine\ORM\Query\AsIsHydrator:
class AsIsHydrator extends AbstractHydrator
{
/**
* Hydrates all rows from the current statement instance at once.
*/
protected function hydrateAllData()
{
return $this->_stmt->fetchAll(\PDO::FETCH_ASSOC);
}
}
Doctrine\ORM\Internal\Hydration\AbstractHydrator:
abstract class AbstractHydrator
{
//...
/**
* Hydrates all rows from the current statement instance at once.
*/
abstract protected function _hydrateAll();
//...
}