aboutsummaryrefslogtreecommitdiff
path: root/model
diff options
context:
space:
mode:
authorMaZderMind2018-05-12 01:57:14 +0200
committerMaZderMind2018-05-12 01:57:14 +0200
commit888bff1972e18a7f32d55fcc23cd4900d03c7d61 (patch)
tree5d4168fb824b5bac202c424682605deb1745b13b /model
parent2cf00ac475500f007bce90cf81d8d582208650c9 (diff)
migrate logic to select current & upcoming talk into the Room class
Diffstat (limited to 'model')
-rw-r--r--model/Room.php20
1 files changed, 20 insertions, 0 deletions
diff --git a/model/Room.php b/model/Room.php
index 7089532..3552f60 100644
--- a/model/Room.php
+++ b/model/Room.php
@@ -4,6 +4,7 @@ class Room
{
private $slug;
private $conference;
+ private $talks;
public function __construct(Conference $conference, $slug)
{
@@ -16,8 +17,27 @@ class Room
throw new NotFoundException('Room '.$slug);
$this->slug = $slug;
+
+ $schedule = $conference->getSchedule();
+ $talksPerRoom = $schedule->getSchedule();
+ $scheduleName = $this->getScheduleName();
+
+ $this->talks = isset($talksPerRoom[$scheduleName]) ? $talksPerRoom[$scheduleName] : [];
}
+ public function getCurrentTalk($now)
+ {
+ return array_filter_last($this->talks, function($talk) use ($now) {
+ return $talk['start'] < $now && $talk['end'] > $now;
+ });
+ }
+
+ public function getNextTalk($now)
+ {
+ return array_filter_first($this->talks, function($talk) use ($now) {
+ return !isset($talk['special']) && $talk['start'] > $now;
+ });
+ }
public function getConference() {
return $this->conference;