summaryrefslogtreecommitdiff
path: root/app/php
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2016-05-13 14:07:25 +0200
committeremkael <emkael@tlen.pl>2016-05-13 14:07:25 +0200
commitfc4266b83a1ad3bbc89ae0858aba4b92284cbfa7 (patch)
tree5f7e5bbe6338af9ec4c29bb6f8d592ed40fb4ecc /app/php
parent77439fe035c1261c81073b674a41a85ef9bf2322 (diff)
* DTO representing a single day of events on calendar grid
Diffstat (limited to 'app/php')
-rw-r--r--app/php/dto/CalendarGridDayDTO.php28
1 files changed, 28 insertions, 0 deletions
diff --git a/app/php/dto/CalendarGridDayDTO.php b/app/php/dto/CalendarGridDayDTO.php
new file mode 100644
index 0000000..ba65eb9
--- /dev/null
+++ b/app/php/dto/CalendarGridDayDTO.php
@@ -0,0 +1,28 @@
+<?php
+
+Prado::using('Application.dto.EventDTO');
+Prado::using('Application.dto.GridEventDTO');
+
+class CalendarGridDayDTO {
+
+ public $Date;
+ public $Events;
+
+ public function __construct(DateTimeImmutable $date, array $events) {
+ $this->Date = $date->format('Y-m-d');
+ $this->Events = array_filter($events, [$this, '_checkEventDate']);
+ // initial sort (date and calendar name)
+ // events are going to be re-sorted after assigning grid priorities
+ usort($this->Events, ['EventDTO', '__compare']);
+ }
+
+ private function _checkEventDate(GridEventDTO $event) {
+ if (!$this->Date) {
+ return FALSE;
+ }
+ return ($this->Date >= $event->DateFrom) && ($this->Date <= $event->DateTo);
+ }
+
+}
+
+?>