From fc4266b83a1ad3bbc89ae0858aba4b92284cbfa7 Mon Sep 17 00:00:00 2001 From: emkael Date: Fri, 13 May 2016 14:07:25 +0200 Subject: * DTO representing a single day of events on calendar grid --- app/php/dto/CalendarGridDayDTO.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 app/php/dto/CalendarGridDayDTO.php 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 @@ +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); + } + +} + +?> -- cgit v1.2.3