mirror of
https://github.com/Icinga/icingaweb2-module-businessprocess.git
synced 2026-01-18 10:32:54 -05:00
Sort Trait: Make $sort nullable and adjust code accordingly
- Update phpDoc
This commit is contained in:
parent
92e982bf3d
commit
35d151b70d
2 changed files with 12 additions and 4 deletions
|
|
@ -10,10 +10,10 @@ use ipl\Stdlib\Str;
|
|||
|
||||
trait Sort
|
||||
{
|
||||
/** @var string Current sort specification */
|
||||
/** @var ?string Current sort specification */
|
||||
protected $sort;
|
||||
|
||||
/** @var callable Actual sorting function */
|
||||
/** @var ?callable Actual sorting function */
|
||||
protected $sortFn;
|
||||
|
||||
/**
|
||||
|
|
@ -29,14 +29,18 @@ trait Sort
|
|||
/**
|
||||
* Set the sort specification
|
||||
*
|
||||
* @param string $sort
|
||||
* @param ?string $sort
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @throws InvalidArgumentException When sorting according to the specified specification is not possible
|
||||
*/
|
||||
public function setSort(string $sort): self
|
||||
public function setSort(?string $sort): self
|
||||
{
|
||||
if (empty($sort)) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
list($sortBy, $direction) = Str::symmetricSplit($sort, ' ', 2, 'asc');
|
||||
|
||||
switch ($sortBy) {
|
||||
|
|
|
|||
|
|
@ -145,6 +145,10 @@ abstract class Renderer extends HtmlDocument
|
|||
*/
|
||||
public function appliesCustomSorting(): bool
|
||||
{
|
||||
if (empty($this->getSort())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
list($sortBy, $_) = Str::symmetricSplit($this->getSort(), ' ', 2);
|
||||
list($defaultSortBy, $_) = Str::symmetricSplit($this->getDefaultSort(), ' ', 2);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue