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


PHP Module::afterAction方法代码示例

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


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

示例1: runAction

 /**
  * Runs an action within this controller with the specified action ID and parameters.
  * If the action ID is empty, the method will use [[defaultAction]].
  * @param string $id the ID of the action to be executed.
  * @param array $params the parameters (name-value pairs) to be passed to the action.
  * @return mixed the result of the action.
  * @throws InvalidRouteException if the requested action ID cannot be resolved into an action successfully.
  * @see createAction()
  */
 public function runAction($id, $params = [])
 {
     $action = $this->createAction($id);
     if ($action !== null) {
         Yii::trace("Route to run: " . $action->getUniqueId(), __METHOD__);
         if (Yii::$app->requestedAction === null) {
             Yii::$app->requestedAction = $action;
         }
         $oldAction = $this->action;
         $this->action = $action;
         $result = null;
         $event = new ActionEvent($action);
         Yii::$app->trigger(Application::EVENT_BEFORE_ACTION, $event);
         if ($event->isValid && $this->module->beforeAction($action) && $this->beforeAction($action)) {
             $result = $action->runWithParams($params);
             $this->afterAction($action, $result);
             $this->module->afterAction($action, $result);
             $event = new ActionEvent($action);
             $event->result =& $result;
             Yii::$app->trigger(Application::EVENT_AFTER_ACTION, $event);
         }
         $this->action = $oldAction;
         return $result;
     } else {
         throw new InvalidRouteException('Unable to resolve the request: ' . $this->getUniqueId() . '/' . $id);
     }
 }
开发者ID:davidpersson,项目名称:FrameworkBenchmarks,代码行数:36,代码来源:Controller.php

示例2: afterAction

 /**
  * Registers user activity after every action.
  * @see \bizley\podium\models\Activity
  * 
  * @param \yii\base\Action $action the action just executed.
  * @param mixed $result the action return result.
  * @return mixed the processed action result.
  */
 public function afterAction($action, $result)
 {
     $parentResult = parent::afterAction($action, $result);
     if (Yii::$app instanceof WebApplication && !in_array($action->id, ['import', 'run'])) {
         Activity::add();
     }
     return $parentResult;
 }
开发者ID:keltstr,项目名称:yii2-podium,代码行数:16,代码来源:Module.php


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