/** * @inheritdoc */ public function afterAction($action, $result) { // save log $log = new models\api\Log(); $log->status = models\api\Log::STATUS_SUCCESS; $log->save(); // generate answer $data = ['status' => models\api\Log::STATUS_SUCCESS, 'data' => $result]; return parent::afterAction($action, $data); }
/** * @inheridoc */ protected function renderException($exception) { $log = new models\api\Log(); $log->status = models\api\Log::STATUS_ERROR; $log->save(); if (Yii::$app->has('response')) { $response = Yii::$app->getResponse(); } else { $response = new Response(); } $response->data = $this->convertExceptionToArray($exception); $response->send(); }