diff options
Diffstat (limited to 'app/php/dto/CalendarGroupDTO.php')
-rw-r--r-- | app/php/dto/CalendarGroupDTO.php | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/app/php/dto/CalendarGroupDTO.php b/app/php/dto/CalendarGroupDTO.php new file mode 100644 index 0000000..3adb6c1 --- /dev/null +++ b/app/php/dto/CalendarGroupDTO.php @@ -0,0 +1,30 @@ +<?php + +Prado::using('Application.model.Category'); +Prado::using('Application.dto.CalendarDTO'); + +class CalendarGroupDTO { + + public $Name; + public $Calendars = array(); + + public function loadRecord(Category $categoryRecord, array $calendars) { + $this->Name = $categoryRecord->Name; + $this->Calendars = array_map( + function($calendarRecord) { + $dto = new CalendarDTO(); + $dto->loadRecord($calendarRecord); + return $dto; + }, + array_filter( + $calendars, + function($calendarRecord) use($categoryRecord) { + return $categoryRecord->ID == $calendarRecord->CategoryID; + } + ) + ); + } + +} + +?> |