Answer the question
In order to leave comments, you need to log in
Why doesn't KnpPaginatorBundle 2.5.3 work in Symfony 3?
Following the prompts in the README.md installed the KnpPaginatorBundle.
But something went wrong and I got a "heel in the nose":
Maybe the controller was configured incorrectly:
public function indexAction(Category $category, Request $request)
{
$paginator = $this->get('knp_paginator');
/** @var \AppBundle\Repository\Offer $rep */
$rep = $this->getDoctrine()->getRepository('AppBundle:Offer');
$offers = $paginator->paginate($rep->queryGetList(), $request->query->getInt('page', 1), 20);
return $this->render('AppBundle:Catalog:new/list.html.twig', [
'category' => $category,
'offers' => $offers,
]);
}
public function queryGetList()
{
$this->query = $this->getEntityManager()->createQueryBuilder()
->from('AppBundle:Offer', 'offer')
->join('offer.category', 'category')
->leftJoin('category.category', 'menu')
->leftJoin('offer.district', 'district')
->andWhere('offer.expireDate >= :expire')
->andWhere('offer.allowed = 1')
->orderBy('offer.payedAdv', 'DESC')
->addOrderBy('offer.updateDate', 'DESC')
->setParameter('expire', date('Y-m-d H:i:s') )
;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question