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


PHP Application::runAction方法代码示例

本文整理汇总了PHP中yii\base\Application::runAction方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::runAction方法的具体用法?PHP Application::runAction怎么用?PHP Application::runAction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在yii\base\Application的用法示例。


在下文中一共展示了Application::runAction方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: runAction

 /**
  * Runs a controller action specified by a route.
  * This method parses the specified route and creates the corresponding child module(s), controller and action
  * instances. It then calls [[Controller::runAction()]] to run the action with the given parameters.
  * If the route is empty, the method will use [[defaultRoute]].
  *
  * For example, to run `public function actionTest($a, $b)` assuming that the controller has options the following
  * code should be used:
  *
  * ```php
  * \Yii::$app->runAction('controller/test', ['option' => 'value', $a, $b]);
  * ```
  *
  * @param string $route the route that specifies the action.
  * @param array $params the parameters to be passed to the action
  * @return integer the status code returned by the action execution. 0 means normal, and other values mean abnormal.
  * @throws Exception if the route is invalid
  */
 public function runAction($route, $params = [])
 {
     try {
         return (int) parent::runAction($route, $params);
     } catch (InvalidRouteException $e) {
         throw new Exception("Unknown command \"{$route}\".", 0, $e);
     }
 }
开发者ID:sadiqhirani,项目名称:yii2,代码行数:26,代码来源:Application.php

示例2: runAction

 /**
  * Runs a controller action specified by a route.
  * This method parses the specified route and creates the corresponding child module(s), controller and action
  * instances. It then calls [[Controller::runAction()]] to run the action with the given parameters.
  * If the route is empty, the method will use [[defaultRoute]].
  *
  * For example, to run `public function actionTest($a, $b)` assuming that the controller has options the following
  * code should be used:
  *
  * ```php
  * \Yii::$app->runAction('controller/test', ['option' => 'value', $a, $b]);
  * ```
  *
  * @param string $route the route that specifies the action.
  * @param array $params the parameters to be passed to the action
  * @return int|Response the result of the action. This can be either an exit code or Response object.
  * Exit code 0 means normal, and other values mean abnormal. Exit code of `null` is treaded as `0` as well.
  * @throws Exception if the route is invalid
  */
 public function runAction($route, $params = [])
 {
     try {
         $res = parent::runAction($route, $params);
         return is_object($res) ? $res : (int) $res;
     } catch (InvalidRouteException $e) {
         throw new Exception("Unknown command \"{$route}\".", 0, $e);
     }
 }
开发者ID:yiisoft,项目名称:yii2,代码行数:28,代码来源:Application.php

示例3: runAction

 /**
  * Runs a controller action specified by a route.
  * This method parses the specified route and creates the corresponding child module(s), controller and action
  * instances. It then calls [[Controller::runAction()]] to run the action with the given parameters.
  * If the route is empty, the method will use [[defaultRoute]].
  * @param string $route the route that specifies the action.
  * @param array $params the parameters to be passed to the action
  * @return integer the status code returned by the action execution. 0 means normal, and other values mean abnormal.
  * @throws Exception if the route is invalid
  */
 public function runAction($route, $params = [])
 {
     try {
         return (int) parent::runAction($route, $params);
     } catch (InvalidRouteException $e) {
         throw new Exception(Yii::t('yii', 'Unknown command "{command}".', ['command' => $route]), 0, $e);
     }
 }
开发者ID:sanggabee,项目名称:hellomedia-yii-basic,代码行数:18,代码来源:Application.php


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