diff options
-rw-r--r-- | app/php/dto/CalendarGroupDTO.php | 2 | ||||
-rw-r--r-- | app/php/facades/CalendarFacade.php | 11 |
2 files changed, 12 insertions, 1 deletions
diff --git a/app/php/dto/CalendarGroupDTO.php b/app/php/dto/CalendarGroupDTO.php index 5f83a71..7b64c6e 100644 --- a/app/php/dto/CalendarGroupDTO.php +++ b/app/php/dto/CalendarGroupDTO.php @@ -6,11 +6,13 @@ Prado::using('Application.dto.CalendarDTO'); class CalendarGroupDTO { public $Name; + public $ID; public $Priority; public $Calendars = []; public function loadRecord(Category $categoryRecord, array $calendars) { $this->Name = $categoryRecord->Name; + $this->ID = $categoryRecord->ID; $this->Priority = $categoryRecord->Priority; $this->Calendars = array_map( function($calendarRecord) { diff --git a/app/php/facades/CalendarFacade.php b/app/php/facades/CalendarFacade.php index b15eac3..5f24e28 100644 --- a/app/php/facades/CalendarFacade.php +++ b/app/php/facades/CalendarFacade.php @@ -143,7 +143,16 @@ class CalendarFacade extends Facade { } public function getCategories() { - return Category::finder()->findAll('ORDER BY name ASC'); + $categories = array_map( + function($record) { + $dto = new CalendarGroupDTO(); + $dto->loadRecord($record, []); + return $dto; + }, + Category::finder()->findAll() + ); + usort($categories, ['CalendarGroupDTO', '__compare']); + return $categories; } public function get($uid) { |