diff --git a/library/Businessprocess/Common/Sort.php b/library/Businessprocess/Common/Sort.php index 3b0f6d4..4728af3 100644 --- a/library/Businessprocess/Common/Sort.php +++ b/library/Businessprocess/Common/Sort.php @@ -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) { diff --git a/library/Businessprocess/Renderer/Renderer.php b/library/Businessprocess/Renderer/Renderer.php index 9917ed6..6aa1363 100644 --- a/library/Businessprocess/Renderer/Renderer.php +++ b/library/Businessprocess/Renderer/Renderer.php @@ -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);