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


PHP Request::getScriptUrl方法代码示例

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


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

示例1: redirectToLanguage

 /**
  * Redirect to the current URL with given language code applied
  *
  * @param string $language the language code to add. Can also be empty to not add any language code.
  */
 protected function redirectToLanguage($language)
 {
     // Examples:
     // 1) /baseurl/index.php/some/page?q=foo
     // 2) /baseurl/some/page?q=foo
     // 3)
     // 4) /some/page?q=foo
     if ($this->showScriptName) {
         // 1) /baseurl/index.php
         // 2) /baseurl/index.php
         // 3) /index.php
         // 4) /index.php
         $redirectUrl = $this->_request->getScriptUrl();
     } else {
         // 1) /baseurl
         // 2) /baseurl
         // 3)
         // 4)
         $redirectUrl = $this->_request->getBaseUrl();
     }
     if ($language) {
         $redirectUrl .= '/' . $language;
     }
     // 1) some/page
     // 2) some/page
     // 3)
     // 4) some/page
     $pathInfo = $this->_request->getPathInfo();
     if ($pathInfo) {
         $redirectUrl .= '/' . $pathInfo;
     }
     if ($redirectUrl === '') {
         $redirectUrl = '/';
     }
     // 1) q=foo
     // 2) q=foo
     // 3)
     // 4) q=foo
     $queryString = $this->_request->getQueryString();
     if ($queryString) {
         $redirectUrl .= '?' . $queryString;
     }
     Yii::$app->getResponse()->redirect($redirectUrl);
     if (YII_ENV_TEST) {
         throw new \yii\base\Exception(\yii\helpers\Url::to($redirectUrl));
     } else {
         Yii::$app->end();
     }
 }
开发者ID:JQL,项目名称:Yii2_Basic_Configuration,代码行数:54,代码来源:UrlManager.php

示例2: Request

<?php

use yii\web\Request;
$params = array_merge(require __DIR__ . '/../../common/config/params.php', require __DIR__ . '/../../common/config/params-local.php', require __DIR__ . '/params.php', require __DIR__ . '/params-local.php');
// Replace url
$request = new Request();
$baseUrlFront = str_replace('/admin', '', $request->getBaseUrl());
$scriptUrlFront = str_replace('/admin', '', $request->getScriptUrl());
return ['id' => 'app-backend', 'basePath' => dirname(__DIR__), 'controllerNamespace' => 'backend\\controllers', 'bootstrap' => ['log', 'common\\components\\BackendBootstrap'], 'modules' => [], 'components' => ['user' => ['identityClass' => 'common\\models\\User', 'enableAutoLogin' => true], 'log' => ['traceLevel' => YII_DEBUG ? 3 : 0, 'targets' => [['class' => 'yii\\log\\FileTarget', 'levels' => ['error', 'warning']]]], 'errorHandler' => ['errorAction' => 'site/error'], 'i18n' => ['translations' => ['writesdown' => ['class' => 'yii\\i18n\\PhpMessageSource', 'basePath' => '@app/messages', 'sourceLanguage' => 'en', 'fileMap' => []]]], 'urlManagerFront' => ['class' => 'yii\\web\\urlManager', 'scriptUrl' => $scriptUrlFront, 'baseUrl' => $baseUrlFront], 'urlManagerBack' => ['class' => 'yii\\web\\urlManager'], 'authManager' => ['class' => 'yii\\rbac\\DbManager']], 'params' => $params];
开发者ID:ochiem,项目名称:app-cms,代码行数:9,代码来源:main.php

示例3: Request

<?php

use yii\web\Request;
$params = array_merge(require __DIR__ . '/../../common/config/params.php', require __DIR__ . '/../../common/config/params-local.php', require __DIR__ . '/params.php', require __DIR__ . '/params-local.php');
// Replace url
$request = new Request();
$baseUrlBack = str_replace('/frontend/web', '/backend/web', $request->getBaseUrl());
$scriptUrlBack = str_replace('/frontend/web', '/backend/web', $request->getScriptUrl());
return ['id' => 'app-frontend', 'basePath' => dirname(__DIR__), 'bootstrap' => ['log'], 'controllerNamespace' => 'frontend\\controllers', 'components' => ['user' => ['identityClass' => 'common\\models\\User', 'enableAutoLogin' => true], 'log' => ['traceLevel' => YII_DEBUG ? 3 : 0, 'targets' => [['class' => 'yii\\log\\FileTarget', 'levels' => ['error', 'warning']]]], 'errorHandler' => ['errorAction' => 'site/error'], 'i18n' => ['translations' => ['writesdown' => ['class' => 'yii\\i18n\\PhpMessageSource', 'basePath' => '@app/messages', 'sourceLanguage' => 'en', 'fileMap' => []]]], 'urlManagerFront' => ['class' => 'yii\\web\\urlManager'], 'urlManagerBack' => ['class' => 'yii\\web\\urlManager', 'scriptUrl' => $scriptUrlBack, 'baseUrl' => $baseUrlBack], 'authManager' => ['class' => 'yii\\rbac\\DbManager']], 'params' => $params];
开发者ID:wozhen,项目名称:yii2-cms-writedown,代码行数:9,代码来源:main.php

示例4: Request

<?php

use yii\web\Request;
$params = array_merge(require __DIR__ . '/../../common/config/params.php', require __DIR__ . '/../../common/config/params-local.php', require __DIR__ . '/params.php', require __DIR__ . '/params-local.php');
// Replace url
$request = new Request();
$baseUrlBack = $request->getBaseUrl() . '/admin';
$scriptUrlBack = str_replace('/index.php', '/admin/index.php', $request->getScriptUrl());
return ['id' => 'app-frontend', 'basePath' => dirname(__DIR__), 'bootstrap' => ['log', 'common\\components\\FrontendBootstrap'], 'controllerNamespace' => 'frontend\\controllers', 'modules' => [], 'components' => ['user' => ['identityClass' => 'common\\models\\User', 'enableAutoLogin' => true], 'log' => ['traceLevel' => YII_DEBUG ? 3 : 0, 'targets' => [['class' => 'yii\\log\\FileTarget', 'levels' => ['error', 'warning']]]], 'errorHandler' => ['errorAction' => 'site/error'], 'i18n' => ['translations' => ['writesdown' => ['class' => 'yii\\i18n\\PhpMessageSource', 'basePath' => '@app/messages', 'sourceLanguage' => 'en', 'fileMap' => []]]], 'urlManagerFront' => ['class' => 'yii\\web\\urlManager'], 'urlManagerBack' => ['class' => 'yii\\web\\urlManager', 'scriptUrl' => $scriptUrlBack, 'baseUrl' => $baseUrlBack], 'authManager' => ['class' => 'yii\\rbac\\DbManager'], 'view' => ['theme' => []]], 'params' => $params];
开发者ID:ochiem,项目名称:app-cms,代码行数:9,代码来源:main.php


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