Sortable: Allow to check for a particular sort rule

This commit is contained in:
Johannes Meyer 2015-06-26 14:54:15 +02:00
parent 9055eb9cb7
commit ae21baa41e
4 changed files with 27 additions and 7 deletions

View File

@ -341,11 +341,25 @@ class SimpleQuery implements QueryInterface, Queryable, Iterator
/** /**
* Whether an order is set * Whether an order is set
* *
* @param string $column
*
* @return bool * @return bool
*/ */
public function hasOrder() public function hasOrder($column = null)
{ {
return !empty($this->order); if (empty($this->order)) {
return false;
} elseif ($column === null) {
return true;
}
foreach ($this->order as $rule) {
if ($rule[0] === $column) {
return true;
}
}
return false;
} }
/** /**

View File

@ -36,9 +36,11 @@ interface Sortable
/** /**
* Whether an order is set * Whether an order is set
* *
* @param string $column
*
* @return bool * @return bool
*/ */
public function hasOrder(); public function hasOrder($column = null);
/** /**
* Get the order if any * Get the order if any

View File

@ -315,11 +315,13 @@ class RepositoryQuery implements QueryInterface, Iterator
/** /**
* Return whether any sort rules were applied to this query * Return whether any sort rules were applied to this query
* *
* @param string $column
*
* @return bool * @return bool
*/ */
public function hasOrder() public function hasOrder($column = null)
{ {
return $this->query->hasOrder(); return $this->query->hasOrder($column);
} }
/** /**

View File

@ -294,11 +294,13 @@ abstract class DataView implements QueryInterface, IteratorAggregate
/** /**
* Whether an order is set * Whether an order is set
* *
* @param string $column
*
* @return bool * @return bool
*/ */
public function hasOrder() public function hasOrder($column = null)
{ {
return $this->query->hasOrder(); return $this->query->hasOrder($column);
} }
/** /**