I have the Problem, that the knp paginator 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) /*page number*/,
8 /*limit per page*/
);
But not in 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) /*page number*/,
/*limit per page*/
);
Why is it like this? I don't understand.
Here´s my twig call :
<li>{{ knp_pagination_sortable(paginator, 'Oldest', 'a.id', {'direction': 'desc'}) }}</li>
Greetings Michael
Attempted to call method "getTemplate" on class "Symfony\Component\HttpFoundation\JsonResponse". (500 Internal Server Error)
– Cosmeticin vendor/knplabs/knp-paginator-bundle/Twig/Extension/PaginationExtension.php at line 56
$template ?: $pagination->getTemplate(),
– Cosmetic