I'm trying to integrate to my Symfony project the KnpPaginatorBundle that allows to paginate entities list.

So I followed the README instructions to install & set-up the bundle as usual.

But when I test an implementation of the KnpPaginatorBundle example (a copy-past implementation), I get the following error:

Fatal error: Class Knp\Component\Pager\Event\Subscriber\Paginate\Doctrine\ORM\Query\AsIsHydrator contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Doctrine\ORM\Internal\Hydration\AbstractHydrator::_hydrateAll) in D:\workspace\wedding\vendor\knp-components\src\Knp\Component\Pager\Event\Subscriber\Paginate\Doctrine\ORM\Query\AsIsHydrator.php on line 13

I didn't find any solutions on Google :-/

Any help is welcome... thanks

My controller:

/**
 * @Route("/pagin", name="pagin")
 * @Template()
 */
public function paginAction(){
    $em    = $this->get('doctrine.orm.entity_manager');
    $dql   = "SELECT c FROM LgpWeddingBundle:Contact c";
    $query = $em->createQuery($dql);

    $paginator  = $this->get('knp_paginator');
    $pagination = $paginator->paginate(
            $query,
            $this->get('request')->query->get('page', 1)/*page number*/,
            10/*limit per page*/
    );

    // parameters to template
    // return $this->render('LgpWeddingBundle:Contact:pagin.html.twig', array('pagination' => $pagination));
    return array('pagination' => $pagination);
}

Knp\Component\Pager\Event\Subscriber\Paginate\Doctrine\ORM\Query\AsIsHydrator:

class AsIsHydrator extends AbstractHydrator
{
    /**
     * Hydrates all rows from the current statement instance at once.
     */
    protected function hydrateAllData()
    {
        return $this->_stmt->fetchAll(\PDO::FETCH_ASSOC);
    }
}

Doctrine\ORM\Internal\Hydration\AbstractHydrator:

abstract class AbstractHydrator
{
    //...

    /**
     * Hydrates all rows from the current statement instance at once.
     */
    abstract protected function _hydrateAll();

    //...
}
1

There are 1 best solutions below

4
On

It seems like that you are using an old version of Doctrin/ORM. In the newest Version it should work. This is probably an issue with the composer.json of the KNPPaginatorBundle, but if you want a fast fix just update doctrine.

Just out of curiousity, have you used Composer to install KNPPaginator? If so could you please provide your versions.

EDIT: I just checked the Bundles and they don't have a dependencie on Doctrine/ORM anyways, so the only solution is to update it manually.