本文整理汇总了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]]]);
}
示例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();
}