/** * @inheritdoc */ public function runAction($id, $params = []) { if (static::skipModelLoad($id) !== self::LOAD_SKIP && isset($params[$this->paramName])) { $this->modelId = $params[$this->paramName]; } return parent::runAction($id, $params); }
public function runAction($route, $params = []) { try { parent::runAction($route, $params); } catch (\Exception $e) { self::_out($this->out($e->getCode() ? $e->getCode() : 1, $e->getMessage())); } }
/** * Assume return is processor if object is returned for action. * @return Response */ public function runAction($id, $params = []) { $result = parent::runAction($id, $params); // assume as Thrift processor if object if (is_object($result) and !$result instanceof Response) { $result = new Response($result); } return $result; }
/** * Runs an action within this controller with the specified action ID and parameters. */ public function runAction($id, $params = []) { $params = \Yii::$app->request->get(); if (false === empty($params['id'])) { static::$configAlias = $params['id']; } $this->configName = empty(static::$configAlias) ? '' : static::$configAlias; $this->getConfig(); if (empty(static::$config)) { throw new NotFoundHttpException(\Yii::t('yii', 'Unknown daemon ID!')); } $this->reloadComponent(); return parent::runAction($id, $params); }
/** * Runs and returns method response * @param $requestObject * @throws \Exception * @throws \yii\web\HttpException * @return Response */ private function getActionResponse($requestObject) { $this->requestObject = $result = $error = null; try { $this->parseAndValidateRequestObject($requestObject); ob_start(); $dirtyResult = parent::runAction($this->requestObject->method); ob_clean(); $result = $this->validateResult($dirtyResult); } catch (HttpException $e) { throw $e; } catch (Exception $e) { $error = $e; } catch (\Exception $e) { $error = new Exception("Internal error", Exception::INTERNAL_ERROR); } if (!isset($this->requestObject->id) && (empty($error) || !in_array($error->getCode(), [Exception::PARSE_ERROR, Exception::INVALID_REQUEST]))) { return null; } return Helper::formatResponse($result, $error, isset($this->requestObject->id) ? $this->requestObject->id : null); }
public function runAction($id, $params = []) { if (Yii::$app->user->isGuest) { throw new \yii\web\NotFoundHttpException(); } $user = Yii::$app->user->identity; if (!$user->isStaff()) { throw new \yii\web\ForbiddenHttpException(); } if ($this->auto_transaction_on) { $conn = Yii::$app->db; $transaction = $conn->beginTransaction(); try { $r = parent::runAction($id, $params); $transaction->commit(); return $r; } catch (\Exception $e) { $transaction->rollBack(); throw $e; } } else { return parent::runAction($id, $params); } }
/** * 根据请求路径自动设置响应格式 * @param string $id * @param array $params * @return mixed|void * @throws \yii\base\InvalidRouteException */ public function runAction($id, $params = []) { if (strpos($id, '.') !== false) { $parts = pathinfo($id); $id = $parts['filename']; $this->setFormat($parts['extension']); } parent::runAction($id, $params); }
/** * @param string $id * @param array $params * @return mixed|\yii\web\Response * @throws \yii\base\InvalidRouteException */ public function runAction($id, $params = []) { // See if it's ok to view this controller->action anonymously $resolvedActionName = $id ? $id : $this->defaultAction; if (!$this->member && !in_array($resolvedActionName, $this->anonActions)) { // nope $this->session->set('redirectAfterLogin', $_SERVER['REQUEST_URI']); return $this->redirect('/login'); } else { return parent::runAction($id, $params); } }