vendor/friendsofsymfony/elastica-bundle/src/Paginator/FantaPaginatorAdapter.php line 35

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the FOSElasticaBundle package.
  4.  *
  5.  * (c) FriendsOfSymfony <http://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 Pagerfanta\Adapter\AdapterInterface;
  12. class FantaPaginatorAdapter implements AdapterInterface
  13. {
  14.     private $adapter;
  15.     /**
  16.      * @param \FOS\ElasticaBundle\Paginator\PaginatorAdapterInterface $adapter
  17.      */
  18.     public function __construct(PaginatorAdapterInterface $adapter)
  19.     {
  20.         $this->adapter $adapter;
  21.     }
  22.     /**
  23.      * Returns the number of results.
  24.      *
  25.      * @return int The number of results
  26.      */
  27.     public function getNbResults()
  28.     {
  29.         return $this->adapter->getTotalHits();
  30.     }
  31.     /**
  32.      * Returns Aggregations.
  33.      *
  34.      * @return mixed
  35.      *
  36.      * @api
  37.      */
  38.     public function getAggregations()
  39.     {
  40.         return $this->adapter->getAggregations();
  41.     }
  42.     /**
  43.      * Returns Suggestions.
  44.      *
  45.      * @return mixed
  46.      *
  47.      * @api
  48.      */
  49.     public function getSuggests()
  50.     {
  51.         return $this->adapter->getSuggests();
  52.     }
  53.     /**
  54.      * Returns a slice of the results.
  55.      *
  56.      * @param int $offset The offset
  57.      * @param int $length The length
  58.      *
  59.      * @return array|\Traversable The slice
  60.      */
  61.     public function getSlice($offset$length)
  62.     {
  63.         return $this->adapter->getResults($offset$length)->toArray();
  64.     }
  65.     /**
  66.      * {@inheritdoc}
  67.      */
  68.     public function getMaxScore()
  69.     {
  70.         return $this->adapter->getMaxScore();
  71.     }
  72. }