summaryrefslogtreecommitdiff
path: root/app/php
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2016-03-12 12:35:30 +0100
committeremkael <emkael@tlen.pl>2016-03-12 12:35:30 +0100
commite4606f2d87be0073bcba02fc5878b768260f4a7f (patch)
tree0cda0cc09a657cc8f5f9dec580898c0c67d402d8 /app/php
parent6096092a455fd640db18e57f54540e35ef51de97 (diff)
* calendar group DTOs
Diffstat (limited to 'app/php')
-rw-r--r--app/php/dto/CalendarDTO.php19
-rw-r--r--app/php/dto/CalendarGroupDTO.php30
2 files changed, 49 insertions, 0 deletions
diff --git a/app/php/dto/CalendarDTO.php b/app/php/dto/CalendarDTO.php
new file mode 100644
index 0000000..302fcf4
--- /dev/null
+++ b/app/php/dto/CalendarDTO.php
@@ -0,0 +1,19 @@
+<?php
+
+Prado::using('Application.model.Calendar');
+
+class CalendarDTO {
+
+ public $ID;
+ public $Name;
+ public $Website;
+
+ public function loadRecord(Calendar $calendarRecord) {
+ $this->ID = $calendarRecord->UID;
+ $this->Name = $calendarRecord->Name;
+ $this->Website = $calendarRecord->Website;
+ }
+
+}
+
+?>
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;
+ }
+ )
+ );
+ }
+
+}
+
+?>