afterAction() public method

public afterAction ( $action, $result )
示例#1
0
 /**
  * @inheritdoc
  * Fix Yii2 Bug #5665: The `currentPage` meta data in the RESTful result should be 1-based, similar to that in HTTP headers
  * There is a similar fix in backend\components\rest\RestController.php
  */
 public function afterAction($action, $result)
 {
     $result = parent::afterAction($action, $result);
     $fixActions = ['message-history'];
     if (in_array($action->id, $fixActions) && isset($result['_meta']['currentPage'])) {
         $result['_meta']['currentPage']++;
     }
     return $result;
 }
示例#2
0
 /**
  * @param \yii\base\Action $action
  * @param mixed            $result
  *
  * @return mixed
  */
 public function afterAction($action, $result)
 {
     $result = parent::afterAction($action, $result);
     /** @noinspection PhpUndefinedFieldInspection */
     if (Yii::$app->has('api') && Yii::$app->api->enableProfiling) {
         list($count, $time) = Yii::getLogger()->getDbProfiling();
         $message = sprintf('Database queries executed: %d, total time: %f sec', $count, $time);
         Yii::getLogger()->log($message, Logger::LEVEL_PROFILE, 'database');
         Yii::endProfile($action->uniqueId);
     }
     return $result;
 }
 /**
  * @inheritdoc
  */
 public function afterAction($action, $result)
 {
     $result = parent::afterAction($action, $result);
     return $this->serializeData($result);
 }