我正在使用 KnpPaginatorBundle。
假设我有这样的事情:
$em = $this->getDoctrine()->getEntityManager();
$qb = $em->createQueryBuilder()
->select('p.id, p.name, p.description)
->from('My\Bundle\Entity\Post', 'p')
->where('p.unread is NULL')
$query = $qb->getQuery();
$posts = $query->getResult();
还有我的分页器:
$paginator = $this->get('knp_paginator');
$posts = $paginator->paginate(
$posts,
$request->query->getInt('page', 1),
3
);
Everythink 工作得很好,但我想通过 foreach 将我自己的数据添加到 $posts。
我的例子不起作用:
foreach ($posts as $key => $value) {
$posts [$key]['filterPath'] = 'example';
}
我收到错误Notice: Indirect modification of overloaded element of Knp\Bundle\PaginatorBundle\Pagination\SlidingPagination has no effect
我该如何解决?问候