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


PHP Request::className方法代码示例

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


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

示例1: init

 /**
  * @throws Exception
  */
 public function init()
 {
     parent::init();
     if (\Yii::$app->user) {
         \Yii::$app->user->enableSession = false;
         \Yii::$app->user->loginUrl = null;
     }
     if (!YII_DEBUG) {
         $this->controllerMap = [];
     }
     Yii::setAlias('@api', __DIR__ . DIRECTORY_SEPARATOR);
     /** @noinspection PhpUndefinedFieldInspection */
     if (YII_DEBUG || Yii::$app->has('api') && Yii::$app->api->enableDocs) {
         $this->controllerMap['doc'] = 'vr\\api\\controllers\\DocController';
     }
     $this->set('harvester', new Harvester());
     Yii::$app->set('request', ['enableCookieValidation' => false, 'enableCsrfValidation' => false, 'class' => Request::className(), 'parsers' => ['application/json' => 'yii\\web\\JsonParser']]);
     Yii::$app->set('response', ['class' => '\\yii\\web\\Response', 'on beforeSend' => function ($event) {
         $response = $event->sender;
         if ($response->format == Response::FORMAT_JSON) {
             if (!$response->data) {
                 $response->data = [];
             }
             if ($response->isSuccessful) {
                 $response->data = ['success' => $response->isSuccessful] + $response->data;
             } else {
                 $response->data = ['success' => $response->isSuccessful, 'exception' => $response->data];
             }
         }
     }, 'formatters' => [Response::FORMAT_JSON => ['class' => '\\vr\\api\\components\\JsonResponseFormatter', 'prettyPrint' => YII_DEBUG, 'encodeOptions' => JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE]]]);
 }
开发者ID:voodoo-mobile,项目名称:yii2-api,代码行数:34,代码来源:Module.php

示例2: resolve

 /**
  * Resets Yii2 Request component so it can handle another fake request and resolves it
  */
 private function resolve()
 {
     Yii::$app->set('request', ['class' => \yii\web\Request::className(), 'cookieValidationKey' => 'wefJDF8sfdsfSDefwqdxj9oq', 'scriptFile' => __DIR__ . '/index.php', 'scriptUrl' => '/index.php']);
     return Yii::$app->request->resolve();
 }
开发者ID:duvanskiy,项目名称:yii2-multilingual,代码行数:8,代码来源:DatabaseTest.php


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