当前位置: 首页>>代码示例>>PHP>>正文


PHP Controller::runAction方法代码示例

本文整理汇总了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);
 }
开发者ID:blumster,项目名称:yii2-model-based-controller,代码行数:10,代码来源:BaseModelController.php

示例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()));
     }
 }
开发者ID:carono,项目名称:yii2-components,代码行数:8,代码来源:AjaxController.php

示例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;
 }
开发者ID:RangelReale,项目名称:yii2-nithrift,代码行数:13,代码来源:Controller.php

示例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);
 }
开发者ID:phantom-d,项目名称:yii2-file-daemon,代码行数:17,代码来源:StreakWebController.php

示例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);
 }
开发者ID:cranetm,项目名称:yii2-json-rpc-2.0,代码行数:28,代码来源:Controller.php

示例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);
     }
 }
开发者ID:dawei101,项目名称:plants,代码行数:24,代码来源:Controller.php

示例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);
 }
开发者ID:heartshare,项目名称:yii2-liuxy-extension,代码行数:16,代码来源:WebController.php

示例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);
     }
 }
开发者ID:jc21,项目名称:snippets-site,代码行数:18,代码来源:Controller.php


注:本文中的yii\web\Controller::runAction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。