['POST'], ]; } /** * @throws NotSupportedException */ public function actionIndex() { throw new NotSupportedException(); } /** * @param int $trigger_id * @return array * @throws NotFoundHttpException */ public function actionTrig($trigger_id) { $trigger = $this->findTrigger($trigger_id); if ($trigger->type !== Trigger::TYPE_MANUAL) { throw new InvalidParamException('This Trigger cannot be triggered by API call'); } $api = new WebSocketAPIBridge(Yii::$app->user->identity); return [ 'success' => $api->trig($trigger_id), ]; } /** * @param int $id * @return Trigger * @throws NotFoundHttpException */ protected function findTrigger($id) { $item = Trigger::findOne($id); if (!$item) { throw new NotFoundHttpException('Trigger was not found'); } return $item; } }