vendor/friendsofsymfony/elastica-bundle/src/Paginator/TransformedPaginatorAdapter.php line 39

Open in your IDE?
  1. <?php
  2. /*
  3. * This file is part of the FOSElasticaBundle package.
  4. *
  5. * (c) FriendsOfSymfony <https://friendsofsymfony.github.com/>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace FOS\ElasticaBundle\Paginator;
  11. use Elastica\Query;
  12. use Elastica\SearchableInterface;
  13. use FOS\ElasticaBundle\Transformer\ElasticaToModelTransformerInterface;
  14. /**
  15. * Allows pagination of \Elastica\Query.
  16. */
  17. class TransformedPaginatorAdapter extends RawPaginatorAdapter
  18. {
  19. private $transformer;
  20. /**
  21. * @param SearchableInterface $searchable the object to search in
  22. * @param Query $query the query to search
  23. * @param ElasticaToModelTransformerInterface $transformer the transformer for fetching the results
  24. */
  25. public function __construct(SearchableInterface $searchable, Query $query, array $options, ElasticaToModelTransformerInterface $transformer)
  26. {
  27. parent::__construct($searchable, $query, $options);
  28. $this->transformer = $transformer;
  29. }
  30. public function getResults($offset, $length)
  31. {
  32. return new TransformedPartialResults($this->getElasticaResults($offset, $length), $this->transformer);
  33. }
  34. }