RepositoryQuery: Implement interface SortRules

refs #6644
This commit is contained in:
Johannes Meyer 2015-07-28 11:41:07 +02:00
parent cdc2182430
commit 05af310e4c
1 changed files with 13 additions and 2 deletions

View File

@ -9,12 +9,13 @@ use Icinga\Application\Benchmark;
use Icinga\Application\Logger;
use Icinga\Data\QueryInterface;
use Icinga\Data\Filter\Filter;
use Icinga\Data\SortRules;
use Icinga\Exception\QueryException;
/**
* Query class supposed to mediate between a repository and its datasource's query
*/
class RepositoryQuery implements QueryInterface, Iterator
class RepositoryQuery implements QueryInterface, SortRules, Iterator
{
/**
* The repository being used
@ -212,6 +213,16 @@ class RepositoryQuery implements QueryInterface, Iterator
return $this->query->getFilter();
}
/**
* Return the sort rules being applied on this query
*
* @return array
*/
public function getSortRules()
{
return $this->repository->getSortRules();
}
/**
* Add a sort rule for this query
*
@ -226,7 +237,7 @@ class RepositoryQuery implements QueryInterface, Iterator
*/
public function order($field = null, $direction = null, $ignoreDefault = false)
{
$sortRules = $this->repository->getSortRules();
$sortRules = $this->getSortRules();
if ($field === null) {
// Use first available sort rule as default
if (empty($sortRules)) {