summaryrefslogtreecommitdiff
path: root/app/php/dto/CalendarGroupDTO.php
blob: 3adb6c1eec7acb143100c106b24737e1e1cefd37 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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;
                }
            )
        );
    }

}

?>