From 174cf79d84869d01489437193129bcddc0ca4169 Mon Sep 17 00:00:00 2001 From: Mark Lewis Date: Thu, 20 Nov 2014 18:16:52 +0100 Subject: [PATCH] clean up shows endpoint, remove dependency on Show model --- .../application/controllers/ApiController.php | 7 +++-- airtime_mvc/application/models/Show.php | 26 ------------------- .../application/models/airtime/CcShow.php | 19 ++++++++++++++ 3 files changed, 22 insertions(+), 30 deletions(-) diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index 240e562c2..6f96a1bf2 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -1394,13 +1394,12 @@ class ApiController extends Zend_Controller_Action $results = array(); if (empty($showId)) { - $shows = Application_Model_Show::getDistinctShows(); - foreach($shows as $baseShow) { - $show = new Application_Model_Show($baseShow->getDbId()); + $shows = CcShowQuery::create()->find(); + foreach($shows as $show) { $results[] = $show->getShowInfo(); } } else { - $show = new Application_Model_Show($showId); + $show = CcShowQuery::create()->findPK($showId); $results[] = $show->getShowInfo(); } diff --git a/airtime_mvc/application/models/Show.php b/airtime_mvc/application/models/Show.php index 4aebc3391..46997e998 100644 --- a/airtime_mvc/application/models/Show.php +++ b/airtime_mvc/application/models/Show.php @@ -786,28 +786,6 @@ SQL; } } - /** - * returns show specific info (not related to isntance) - */ - public function getShowInfo() - { - $info = array(); - if ($this->getId() == null) { - return $info; - } else { - $ccShow = CcShowQuery::create()->findPK($this->_showId); - $info['name'] = $ccShow->getDbName(); - $info['id'] = $ccShow->getDbId(); - $info['url'] = $ccShow->getDbUrl(); - $info['genre'] = $ccShow->getDbGenre(); - $info['description'] = $ccShow->getDbDescription(); - $info['color'] = $ccShow->getDbColor(); - $info['background_color'] = $ccShow->getDbBackgroundColor(); - $info['linked'] = $ccShow->getDbLinked(); - return $info; - } - } - /* Only used for shows that are repeating. Note that this will return * true even for dates that only have a "modified" show instance (does not * check if the "modified_instance" column is set to true). This is intended @@ -1482,8 +1460,4 @@ SQL; return array($start, $end); } - public static function getDistinctShows() { - $shows = CcShowQuery::create()->find(); - return $shows; - } } diff --git a/airtime_mvc/application/models/airtime/CcShow.php b/airtime_mvc/application/models/airtime/CcShow.php index b9f140e3e..ee0c75454 100644 --- a/airtime_mvc/application/models/airtime/CcShow.php +++ b/airtime_mvc/application/models/airtime/CcShow.php @@ -304,4 +304,23 @@ class CcShow extends BaseCcShow { ->filterByDbId($instanceId, Criteria::NOT_EQUAL) ->find(); } + + public function getShowInfo() + { + $info = array(); + if ($this->getDbId() == null) { + return $info; + } else { + $info['name'] = $this->getDbName(); + $info['id'] = $this->getDbId(); + $info['url'] = $this->getDbUrl(); + $info['genre'] = $this->getDbGenre(); + $info['description'] = $this->getDbDescription(); + $info['color'] = $this->getDbColor(); + $info['background_color'] = $this->getDbBackgroundColor(); + $info['linked'] = $this->getDbLinked(); + return $info; + } + + } } // CcShow