src/Util/Paginator.php
public function pagination($query, $options = [])
    {
        $this->options = array_replace($this->app['paginator.options'], $options);

        switch (true) {
            case $query instanceof \Doctrine\ORM\QueryBuilder:
                $adapter = new \Pagination\Adapter\PaginationORMAdapter();
                break;
            case is_array($query):
                $adapter = new \Pagination\Adapter\PaginationArrayAdapter();
                break;
            default:
                throw new \Pagination\Exception\UnknownAdapterException();
        }

        $current = 1;
        if ($this->app['request_stack']->getCurrentRequest()) {
            $current = $this->app['request_stack']->getCurrentRequest()->get('page', 1);
        }
        $counter = $adapter->getCounter($query);

        $items = ceil($counter / $this->options['items_per_page']);

        return [
            'first'      => 1,
            'prev'       => $current > 1 ? $current - 1 : null,
            'current'    => $current,
            'items'      => $adapter->getItems($query, $current, $this->options['items_per_page']),
            'pages'      => $this->getPages($current, $items),
            'next'       => $current < $items ? $current + 1 : null,
            'last'       => $items,
            'total'      => $counter,
            'total_page' => $items,
            'options'    => $this->options,
        ];
    }
public function pagination($query, $options = [])
    {
        $this->options = array_replace($this->app['paginator.options'], $options);

        switch (true) {
            case $query instanceof \Doctrine\ORM\QueryBuilder:
                $adapter = new \Pagination\Adapter\PaginationORMAdapter();
                break;
            case is_array($query):
                $adapter = new \Pagination\Adapter\PaginationArrayAdapter();
                break;
            default:
                throw new \Pagination\Exception\UnknownAdapterException();
        }

        $current = 1;
        if ($this->app['request_stack']->getCurrentRequest()) {
            $current = $this->app['request_stack']->getCurrentRequest()->get('page', 1);
        }
        $counter = $adapter->getCounter($query);

        $items = ceil($counter / $this->options['items_per_page']);

        return [
            'first'      => 1,
            'prev'       => $current > 1 ? $current - 1 : null,
            'current'    => $current,
            'items'      => $adapter->getItems($query, $current, $this->options['items_per_page']),
            'pages'      => $this->getPages($current, $items),
            'next'       => $current < $items ? $current + 1 : null,
            'last'       => $items,
            'total'      => $counter,
            'total_page' => $items,
            'options'    => $this->options,
        ];
    }
@param \Doctrine\ORM\QueryBuilder|array $query
@param array                      $options

@throws \Pagination\Exception\UnknownAdapterException

@return array