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


PHP ActiveController::afterAction方法代码示例

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


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

示例1: afterAction

 /**
  * @inheritdoc
  */
 public function afterAction($action, $result)
 {
     $result = parent::afterAction($action, $result);
     $result = $this->serializeData($result);
     if (!isset($result['code'])) {
         return ApiHelper::successResponse($result);
     }
     return $result;
 }
开发者ID:pylypen,项目名称:api-side,代码行数:12,代码来源:StudioController.php

示例2: afterAction

 public function afterAction($action, $result)
 {
     $result = parent::afterAction($action, $result);
     $token_info = Yii::$app->getResponse()->content;
     if (!is_null($token_info)) {
         $result += Yii::$app->getResponse()->content;
     }
     return $result;
 }
开发者ID:Olwn,项目名称:pm25,代码行数:9,代码来源:CheckTokenController.php

示例3: afterAction

 /**
  * @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\Controller.php
  */
 public function afterAction($action, $result)
 {
     $result = parent::afterAction($action, $result);
     $pageFixActions = ['member'];
     if (('index' === $action->id || in_array($action->id, $pageFixActions)) && isset($result['_meta']['currentPage'])) {
         $result['_meta']['currentPage']++;
     }
     return $result;
 }
开发者ID:timelessmemory,项目名称:uhkklp,代码行数:14,代码来源:RestController.php

示例4: getLargeResponse

 /**
  * Returns an open renderer stream that outputs formatted items from the dataProvider.
  * @param Action $action the action just executed.
  * @param mixed $result  the action return result.
  * @param array $params params extracted from result
  * @return Response
  * @throws Exception when failed to register the renderer stream class
  * @throws \HttpInvalidParamException
  */
 protected function getLargeResponse($action, $result, $params)
 {
     parent::afterAction($action, $result);
     $format = Yii::$app->response->format;
     /** @var stream\RendererStream $rendererClass */
     switch ($format) {
         case Response::FORMAT_CSV:
             $rendererClass = 'netis\\utils\\crud\\stream\\CsvRendererStream';
             break;
         case Response::FORMAT_JSON:
             $rendererClass = 'netis\\utils\\crud\\stream\\JsonRendererStream';
             break;
         case Response::FORMAT_XML:
             $rendererClass = 'netis\\utils\\crud\\stream\\XmlRendererStream';
             break;
         case Response::FORMAT_XLS:
             $rendererClass = 'netis\\utils\\crud\\stream\\XlsRendererStream';
             break;
         default:
             throw new \HttpInvalidParamException('Unsupported format requested: ' . $format);
     }
     $streamName = $format . 'View';
     if (!stream_wrapper_register($streamName, $rendererClass)) {
         throw new Exception('Failed to register the RenderStream wrapper.');
     }
     $rendererClass::$params = $params;
     $response = new \yii\web\Response();
     $response->setDownloadHeaders($action->id . '.' . $format, Yii::$app->response->acceptMimeType);
     $response->format = Response::FORMAT_RAW;
     $streamParams = ['format' => $format, 'serializer' => $this->serializer];
     $response->stream = fopen("{$streamName}://{$action->id}?" . \http_build_query($streamParams), "r");
     return $response;
 }
开发者ID:netis-pl,项目名称:yii2-crud,代码行数:42,代码来源:ActiveController.php

示例5: afterAction

 public function afterAction($action, $result)
 {
     $result = parent::afterAction($action, $result);
     if (Yii::$app->response->format == \yii\web\Response::FORMAT_JSONP) {
         if (isset($_GET['callback'])) {
             $result = array('callback' => $_GET['callback'], 'data' => $result);
         }
     }
     /*
      * CORS requires some headers in order for the requests to work. 
      * These are current working headers for the app.
      * 
      * We may want to move this to a better location, or maybe change 
      * the entire Header-logic.
      */
     Yii::$app->getResponse()->getHeaders()->set('Access-Control-Allow-Credentials', 'true');
     Yii::$app->getResponse()->getHeaders()->set('Access-Control-Allow-Origin', Yii::$app->request->getHeaders()->get('Origin'));
     Yii::$app->getResponse()->getHeaders()->set('Access-Control-Allow-Headers', 'Authorization');
     $headers = implode(',', array_keys(Yii::$app->response->getHeaders()->toArray()));
     Yii::$app->getResponse()->getHeaders()->set('Access-Control-Expose-Headers', $headers);
     return $result;
 }
开发者ID:RHeSuS-project,项目名称:POC-service,代码行数:22,代码来源:XActiveController.php

示例6: afterAction

 public function afterAction($action, $result)
 {
     if (!$this->handleAfterActionEvent($action, $result)) {
         $msg = "Failed to do after action, action: " . $action->id . ' class is: ' . $this::className();
         throw new \Exception($msg);
     }
     return parent::afterAction($action, $result);
 }
开发者ID:dawei101,项目名称:plants,代码行数:8,代码来源:ApiController.php


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