diff options
author | MaZderMind | 2015-03-15 19:13:25 +0100 |
---|---|---|
committer | MaZderMind | 2015-03-29 21:42:01 +0200 |
commit | ea4b6c7699a7fbb7be3d9e5ce86c84a36b63f569 (patch) | |
tree | c919029a8b12e43c363b898a1ff9f7adf5c3312b /model/StreamList.php | |
parent | 97fe6bf0af2989abbaaba138df3c54c4e55af3c9 (diff) |
Move get/set-Calls into ModelBase and abstract all access into a Model
Conflicts:
model/Overview.php
model/Room.php
model/StreamList.php
tests/ModelTestbase.php
Diffstat (limited to '')
-rw-r--r-- | model/StreamList.php | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/model/StreamList.php b/model/StreamList.php index 531a787..d203a52 100644 --- a/model/StreamList.php +++ b/model/StreamList.php @@ -1,9 +1,35 @@ <?php -class StreamList implements AggregateIterator +class StreamList extends ModelBase implements IteratorAggregate { private $streams = array(); + public function __construct($slug) + { + if(! $this->has('ROOMS.'.$slug)) + throw new NotFoundException('Room '.$slug); + + $this->slug = $slug; + $this->streams = array(); + + $streams = $this->get("ROOMS.$slug.STREAMS"); + foreach((array)$streams as $stream) { + $this->streams[$stream] = explode('-', $stream); + } + } + + public function getRoomSlug() { + return $this->slug; + } + + public function getRoom() { + return new Room($this->getRoomSlug()); + } + + public function getStreams() { + return array_keys($this->streams); + } + public function getIterator() { return new ArrayIterator($this->streams); } |