Skip to content

Latest commit

 

History

History
43 lines (34 loc) · 1.21 KB

manual-provider.md

File metadata and controls

43 lines (34 loc) · 1.21 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 FOS\ElasticaBundle\Provider\PagerInterface;
use Pagerfanta\Pagerfanta;
use Pagerfanta\Adapter\ArrayAdapter;

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

There are some examples:

Back to index