I have a problem that paginator knp only works like this:
$em = $this->get('doctrine.orm.entity_manager'); $dql = "SELECT a FROM MainArtBundle:Art a"; $query = $em->createQuery($dql); $paginator = $this->get('knp_paginator'); $pagination = $paginator->paginate( $query, $this->get('request')->query->get('page', 1) , 8 );
But not this way:
$em = $this->getDoctrine()->getManager(); $entities = $em->getRepository('MainArtBundle:Art')->findAll(); $paginator = $this->get('knp_paginator'); $pagination = $paginator->paginate( $entities, $this->get('request')->query->get('page', 1) , );
Why is that? I do not understand.
Here is my call:
<li>{{ knp_pagination_sortable(paginator, 'Oldest', 'a.id', {'direction': 'desc'}) }}</li>
Greetings Michael
source share