afterAction() public method

You may override this method to do some postprocessing for the action.
public afterAction ( Action $action, mixed $result ) : mixed
$action Action the action just executed.
$result mixed the action execution result
return mixed the processed action result.
Example #1
0
 public function afterAction($action, $result)
 {
     $res = parent::afterAction($action, $result);
     if ($this->ajaxMode) {
         if ($res) {
             $dom = Yii::createObject(['class' => Dom::className(), 'html' => $res]);
             if (!empty($_REQUEST['target_id'])) {
                 $target_id = explode(',', $_REQUEST['target_id']);
                 $this->ajaxVars['html'] = $dom->getElementByIds($target_id);
             }
             list($scripts, $src) = $dom->getScripts();
             if ($scripts) {
                 $this->ajaxVars['scripts'] = $scripts;
             }
             if ($src && 0) {
                 // disabled
                 $this->ajaxVars['scripts_src'] = $src;
             }
         }
         // Flashes
         if (!isset($this->ajaxVars['alerts'])) {
             $this->ajaxVars['alerts'] = Yii::$app->session->getAllFlashes();
         }
         Yii::$app->response->format = 'json';
         return $this->ajaxVars;
     }
     return $res;
 }
 /**
  * This method is invoked right after an action is executed.
  * You may override this method to do some postprocessing for the action.
  * @param Action $action the action just executed.
  * @param mixed $result the action execution result
  * @return mixed the processed action result.
  */
 public function afterAction($action, $result)
 {
     $usedTime = microtime(TRUE) - $this->_startTime;
     $logContent = "Action:'{$action->uniqueId}' spent {$usedTime} seconds";
     $appLog = new AppLog(['log_content' => $logContent]);
     $appLog->save();
     return parent::afterAction($action, $result);
 }
Example #3
0
 public function afterAction($action, $result)
 {
     return parent::afterAction($action, $result);
 }
 public function afterAction($action, $result)
 {
     $time = microtime(true) - $this->_startTime;
     Yii::trace("Action '{$action->uniqueId}' spent {$time} second.");
     return parent::afterAction($action, $result);
 }
Example #5
0
 /**
  * @inheritdoc
  */
 public function afterAction($action, $result)
 {
     $parentsResults = parent::afterAction($action, $result);
     Url::rememberStack();
     return $parentsResults;
 }