예제 #1
0
 /**
  * @param text $statusName
  */
 public function getList($statusName)
 {
     if (!$this->application->request->isGet()) {
         throw new Exception('Method not allowed', 405);
     }
     $statuses = Status::find();
     $statusesArr = $statuses->toArray('name');
     if (!in_array($statusName, $statusesArr)) {
         throw new Exception('Invalid paremeter', 409);
     }
     $status = Status::findFirst(array('conditions' => 'name = :name:', 'bind' => array('name' => $statusName)));
     $songs = Song::find(array('conditions' => 'status_id = :id:', 'bind' => array('id' => $status->getId()), 'order' => 'number ASC', 'group' => 'production_id'));
     if (!$songs) {
         throw new Exception('Query not executed', 500);
     }
     if ($songs->count() == 0) {
         return array('code' => 204, 'content' => 'No matching Song instance found');
     }
     return array('code' => 200, 'content' => $songs->toArray());
 }
예제 #2
0
 /**
  * @param integer $productionId
  */
 public function getSongs($productionId)
 {
     if (!$this->application->request->isGet()) {
         throw new Exception('Method not allowed', 405);
     }
     $production = Production::findFirst($productionId);
     if (!$production) {
         throw new Exception('Production instance not found', 404);
     }
     $songs = Song::find(array('conditions' => 'production_id = :pId:', 'bind' => array('pId' => $productionId), 'order' => 'number ASC'));
     if (!$songs) {
         throw new Exception('Query not executed', 500);
     }
     if ($songs->count() == 0) {
         return array('code' => 204, 'content' => 'No Song instance found for this Production instance');
     }
     return array('code' => 200, 'content' => $songs->toArray());
 }