Skip to content

Latest commit

 

History

History
42 lines (33 loc) · 1.15 KB

manual-provider.md

File metadata and controls

42 lines (33 loc) · 1.15 KB

Manual pager provider

Create a service with the tag "fos_elastica.pager_provider" and attribute "index" for the index for which the service will provide.

# app/config/config.yml
services:
    acme.search_provider.user:
        class: Acme\UserBundle\Provider\UserPagerProvider
        tags:
            - { name: fos_elastica.pager_provider, index: user }

Its class must implement FOS\ElasticaBundle\Provider\PagerProviderInterface.

<?php
namespace Acme\UserBundle\Provider;

use FOS\ElasticaBundle\Provider\PagerProviderInterface;
use FOS\ElasticaBundle\Provider\PagerfantaPager;
use Pagerfanta\Pagerfanta;
use Pagerfanta\Adapter\ArrayAdapter;

class UserPagerProvider implements PagerProviderInterface
{
    public function provide(array $options = [])
    {
        return new PagerfantaPager(new Pagerfanta(new ArrayAdapter([ /* an array of objects */ ])));
    }
}

There are some examples:

Back to index