From 668ce7487a1c61438213e9efb705c5c804aace8b Mon Sep 17 00:00:00 2001 From: emkael Date: Tue, 10 May 2016 00:27:27 +0200 Subject: * sorting calendar groups by priority --- app/php/dto/CalendarGroupDTO.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'app/php') 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); } -- cgit v1.2.3