diff options
author | emkael <emkael@tlen.pl> | 2016-05-10 00:27:27 +0200 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2016-05-10 00:27:27 +0200 |
commit | 668ce7487a1c61438213e9efb705c5c804aace8b (patch) | |
tree | 7b7c8ef91a28f63cbcd87454b0ec97b5d0077ad1 | |
parent | 33a9cefdcfbf5177b0a72ef42da4a98fca8761fe (diff) |
* sorting calendar groups by priority
-rw-r--r-- | app/php/dto/CalendarGroupDTO.php | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/app/php/dto/CalendarGroupDTO.php b/app/php/dto/CalendarGroupDTO.php index a03afde..5f83a71 100644 --- a/app/php/dto/CalendarGroupDTO.php +++ b/app/php/dto/CalendarGroupDTO.php @@ -6,10 +6,12 @@ Prado::using('Application.dto.CalendarDTO'); class CalendarGroupDTO { public $Name; + public $Priority; public $Calendars = []; public function loadRecord(Category $categoryRecord, array $calendars) { $this->Name = $categoryRecord->Name; + $this->Priority = $categoryRecord->Priority; $this->Calendars = array_map( function($calendarRecord) { $dto = new CalendarDTO(); @@ -28,6 +30,10 @@ class CalendarGroupDTO { public static function __compare(CalendarGroupDTO $cat1, CalendarGroupDTO $cat2) { + $cmp = ($cat1->Priority ?: PHP_MAX_INT) - ($cat2->Priority ?: PHP_MAX_INT); + if ($cmp !== 0) { + return $cmp; + } return strcmp($cat1->Name, $cat2->Name); } |