CS
This commit is contained in:
parent
33397ec467
commit
2bf7344fbb
6 changed files with 16 additions and 13 deletions
|
|
@ -4,12 +4,13 @@ namespace FOQ\ElasticaBundle\Finder;
|
|||
|
||||
interface FinderInterface
|
||||
{
|
||||
/**
|
||||
/**
|
||||
* Searches for query results within a given limit
|
||||
*
|
||||
* @param mixed $query Can be a string, an array or an Elastica_Query object
|
||||
* @param int $limit How many results to get
|
||||
* @param mixed $query Can be a string, an array or an Elastica_Query object
|
||||
* @param int $limit How many results to get
|
||||
*
|
||||
* @return array results
|
||||
*/
|
||||
function find($query, $limit);
|
||||
function find($query, $limit);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ class RawFinder implements FinderInterface, PaginatedFinderInterface
|
|||
**/
|
||||
public function find($query, $limit)
|
||||
{
|
||||
$queryObject = Elastica_Query::create($query);
|
||||
$queryObject = Elastica_Query::create($query);
|
||||
$queryObject->setLimit($limit);
|
||||
|
||||
return $this->searchable->search($queryObject)->getResults();
|
||||
|
|
@ -40,20 +40,21 @@ class RawFinder implements FinderInterface, PaginatedFinderInterface
|
|||
**/
|
||||
public function findPaginated($query)
|
||||
{
|
||||
$queryObject = Elastica_Query::create($query);
|
||||
$paginatorAdapter = $this->createPaginatorAdapter($queryObject);
|
||||
$queryObject = Elastica_Query::create($query);
|
||||
$paginatorAdapter = $this->createPaginatorAdapter($queryObject);
|
||||
|
||||
return new Pagerfanta(new FantaPaginatorAdapter($paginatorAdapter));
|
||||
return new Pagerfanta(new FantaPaginatorAdapter($paginatorAdapter));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a paginator adapter for this query
|
||||
*
|
||||
* @param Elastica_Query $query
|
||||
*
|
||||
* @return RawPaginatorAdapter
|
||||
*/
|
||||
public function createPaginatorAdapter(Elastica_Query $query)
|
||||
{
|
||||
return new RawPaginatorAdapter($this->searchable, $query);
|
||||
return new RawPaginatorAdapter($this->searchable, $query);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ class TransformedFinder implements FinderInterface, PaginatedFinderInterface
|
|||
* Gets a paginator wrapping the result of a search
|
||||
*
|
||||
* @return Pagerfanta
|
||||
**/
|
||||
*/
|
||||
public function findPaginated($query)
|
||||
{
|
||||
$queryObject = Elastica_Query::create($query);
|
||||
|
|
@ -75,6 +75,7 @@ class TransformedFinder implements FinderInterface, PaginatedFinderInterface
|
|||
* Creates a paginator adapter for this query
|
||||
*
|
||||
* @param Elastica_Query $query
|
||||
*
|
||||
* @return TransformedPaginatorAdapter
|
||||
*/
|
||||
public function createPaginatorAdapter(Elastica_Query $query)
|
||||
|
|
|
|||
|
|
@ -41,6 +41,6 @@ class FantaPaginatorAdapter implements AdapterInterface
|
|||
*/
|
||||
public function getSlice($offset, $length)
|
||||
{
|
||||
return $this->adapter->getResults($offset,$length)->toArray();
|
||||
return $this->adapter->getResults($offset, $length)->toArray();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ class RawPaginatorAdapter implements PaginatorAdapterInterface
|
|||
*/
|
||||
public function getResults($offset, $itemCountPerPage)
|
||||
{
|
||||
return new RawPartialResults($this->getElasticaResults($offset,$itemCountPerPage));
|
||||
return new RawPartialResults($this->getElasticaResults($offset, $itemCountPerPage));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -31,6 +31,6 @@ class TransformedPaginatorAdapter extends RawPaginatorAdapter
|
|||
*/
|
||||
public function getResults($offset, $length)
|
||||
{
|
||||
return new TransformedPartialResults($this->getElasticaResults($offset,$length),$this->transformer);
|
||||
return new TransformedPartialResults($this->getElasticaResults($offset, $length), $this->transformer);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue