I
I
Ivan Antonov2016-06-30 16:09:28
symfony
Ivan Antonov, 2016-06-30 16:09:28

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":
16d8e40628fb496eae6e10420eb4dedb.PNG
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,
        ]);
    }

And just in case the request method:
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') )
        ;
    }

Tell me where I messed up and how to fix it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
BoShurik, 2016-06-30
@antonowano

Forgot return in queryGetList method

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question