<commit_before><?php

namespace Knp\IpsumBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Pagerfanta\Pagerfanta;
use Pagerfanta\Adapter\DoctrineORMAdapter;

class PagerfantaController extends Controller
{
    public function indexAction()
    {
        $em = $this->get('doctrine')->getEntityManager();
        /* @var $em \Doctrine\ORM\EntityManager */
        $query = $em->createQuery('SELECT t FROM KnpIpsumBundle:Thing t');
        $paginator = new Pagerfanta(new DoctrineORMAdapter($query));
        $paginator->setMaxPerPage(10);
        $paginator->setCurrentPage($this->get('request')->query->get('page', 1));

        return $this->render('KnpIpsumBundle:Pagerfanta:index.html.twig', array(
            'paginator' => $paginator,
        ));
    }
}<commit_msg>Avoid exception when the page number is too high.<commit_after><?php

namespace Knp\IpsumBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Pagerfanta\Pagerfanta;
use Pagerfanta\Adapter\DoctrineORMAdapter;

class PagerfantaController extends Controller
{
    public function indexAction()
    {
        $em = $this->get('doctrine')->getEntityManager();
        /* @var $em \Doctrine\ORM\EntityManager */
        $query = $em->createQuery('SELECT t FROM KnpIpsumBundle:Thing t');
        $paginator = new Pagerfanta(new DoctrineORMAdapter($query));
        $paginator->setMaxPerPage(10);
        $paginator->setCurrentPage($this->get('request')->query->get('page', 1), false, true);

        return $this->render('KnpIpsumBundle:Pagerfanta:index.html.twig', array(
            'paginator' => $paginator,
        ));
    }
}
{'fraction_non_alphanumeric': 0.14061557030778515, 'fraction_numerical': 0.003621001810500905, 'mean_word_length': 3.8197674418604652, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5040806', 'n_tokens_mistral': 524, 'n_tokens_neox': 518, 'n_words': 88}