當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。