private function getPager(Query $query, QueryDefinition $queryDefinition)
    {
        if ($queryDefinition->useFilter) {
            $adapter = new FilterAdapter($query, $this->filterService);
        } else {
            $adapter = new FindAdapter($query, $this->findService);
        }

        $pager = new Pagerfanta($adapter);

        $pager->setNormalizeOutOfRangePages(true);
        $pager->setMaxPerPage($queryDefinition->maxPerPage);
        $pager->setCurrentPage($queryDefinition->page);

        return $pager;
    }