/** * @param integer $broadcastTypeId */ public function delete($broadcastTypeId) { if (!$this->application->request->isDelete()) { throw new Exception('Method not allowed', 405); } if (!$this->isAllowed()) { throw new Exception('User not authorized', 401); } $bt = BroadcastType::findFirst($broadcastTypeId); if (!$bt) { throw new Exception('BroadcastType not found', 404); } if (!$bt->delete()) { throw new Exception('BroadcastType not deleted', 409); } return array('code' => 204, 'content' => 'BroadcastType deleted'); }
/** * @param JSON $postData * @return boolean */ public function beforeCreate($postData) { $bt = BroadcastType::findFirst(array('name' => $postData->name)); return $bt ? false : true; }