本文整理汇总了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);
}
}