Sortable: Allow to check for a particular sort rule
This commit is contained in:
parent
9055eb9cb7
commit
ae21baa41e
|
@ -341,11 +341,25 @@ class SimpleQuery implements QueryInterface, Queryable, Iterator
|
|||
/**
|
||||
* Whether an order is set
|
||||
*
|
||||
* @param string $column
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -36,9 +36,11 @@ interface Sortable
|
|||
/**
|
||||
* Whether an order is set
|
||||
*
|
||||
* @param string $column
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasOrder();
|
||||
public function hasOrder($column = null);
|
||||
|
||||
/**
|
||||
* Get the order if any
|
||||
|
|
|
@ -315,11 +315,13 @@ class RepositoryQuery implements QueryInterface, Iterator
|
|||
/**
|
||||
* Return whether any sort rules were applied to this query
|
||||
*
|
||||
* @param string $column
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasOrder()
|
||||
public function hasOrder($column = null)
|
||||
{
|
||||
return $this->query->hasOrder();
|
||||
return $this->query->hasOrder($column);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -294,11 +294,13 @@ abstract class DataView implements QueryInterface, IteratorAggregate
|
|||
/**
|
||||
* Whether an order is set
|
||||
*
|
||||
* @param string $column
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasOrder()
|
||||
public function hasOrder($column = null)
|
||||
{
|
||||
return $this->query->hasOrder();
|
||||
return $this->query->hasOrder($column);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue