summaryrefslogtreecommitdiff
path: root/app/php/facades
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2016-05-06 12:44:53 +0200
committeremkael <emkael@tlen.pl>2016-05-06 12:44:53 +0200
commit63c72a0bff307162859d09daf9380ca43cdb3b4c (patch)
tree1317ce38adc514cc6d41fe2961a49e8a165fe7de /app/php/facades
parent29c9678df8a1a6285af3501b3c0b2ca2f57d358e (diff)
* calendar facade method for accessing events
Diffstat (limited to 'app/php/facades')
-rw-r--r--app/php/facades/CalendarFacade.php25
1 files changed, 25 insertions, 0 deletions
diff --git a/app/php/facades/CalendarFacade.php b/app/php/facades/CalendarFacade.php
index 71ddcb4..25dec5f 100644
--- a/app/php/facades/CalendarFacade.php
+++ b/app/php/facades/CalendarFacade.php
@@ -1,6 +1,7 @@
<?php
Prado::using('Application.facades.Facade');
+Prado::using('Application.facades.EventFacade');
Prado::using('Application.dto.CalendarDTO');
Prado::using('Application.dto.CalendarGroupDTO');
Prado::using('Application.model.Calendar');
@@ -51,6 +52,30 @@ class CalendarFacade extends Facade {
}
}
+ public function getEventsForTimeframe(CalendarDTO $calendar,
+ DateTime $dateFrom,
+ DateTime $dateTo,
+ $order = 'ASC') {
+ $calendar = Calendar::finder()->findAllByUID($calendar->ID);
+ if ($calendar) {
+ $events = EventFacade::getInstance()->getEventList(
+ $dateFrom->format('Y-m-d H:i:s'),
+ $dateTo->format('Y-m-d H:i:s'),
+ $calendar,
+ $order
+ );
+ return array_map(
+ function($event) use($calendar) {
+ $dto = new EventDTO();
+ $dto->loadRecord($event, $calendar);
+ return $dto;
+ },
+ $events
+ );
+ }
+ return [];
+ }
+
public function getAll() {
return Calendar::finder()->withCategory()->findAll('ORDER BY name ASC');
}