本文整理匯總了PHP中yii\web\Controller::runAction方法的典型用法代碼示例。如果您正苦於以下問題:PHP Controller::runAction方法的具體用法?PHP Controller::runAction怎麽用?PHP Controller::runAction使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類yii\web\Controller
的用法示例。
在下文中一共展示了Controller::runAction方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: runAction
/**
* @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);
}
示例2: runAction
public function runAction($route, $params = [])
{
try {
parent::runAction($route, $params);
} catch (\Exception $e) {
self::_out($this->out($e->getCode() ? $e->getCode() : 1, $e->getMessage()));
}
}
示例3: runAction
/**
* 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;
}
示例4: runAction
/**
* 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);
}
示例5: getActionResponse
/**
* 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);
}
示例6: runAction
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);
}
}
示例7: runAction
/**
* 根據請求路徑自動設置響應格式
* @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);
}
示例8: runAction
/**
* @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);
}
}