没有命名空间的类 yii yii\base yii\behaviors yii\caching yii\captcha yii\console yii\console\controllers yii\console\widgets yii\data yii\db yii\db\conditions yii\db\cubrid yii\db\cubrid\conditions yii\db\mssql yii\db\mssql\conditions yii\db\mysql yii\db\oci yii\db\oci\conditions yii\db\pgsql yii\db\sqlite yii\db\sqlite\conditions yii\di yii\filters yii\filters\auth yii\grid yii\helpers yii\i18n yii\log yii\mail yii\mutex yii\rbac yii\rest yii\test yii\validators yii\web yii\widgets

Class yii\web\UrlNormalizer

继承yii\web\UrlNormalizer » yii\base\BaseObject
实现yii\base\Configurable
可用版本自2.0.10
源码 https://github.com/yiichina/yii2/blob/api/framework/web/UrlNormalizer.php

UrlNormalizer normalizes URLs for yii\web\UrlManager and yii\web\UrlRule.

公共属性

隐藏继承的属性

属性类型描述被定义在
$action integer|callable|null Action to perform during route normalization. yii\web\UrlNormalizer
$collapseSlashes boolean Whether slashes should be collapsed, for example site///index will be converted into site/index yii\web\UrlNormalizer
$normalizeTrailingSlash boolean Whether trailing slash should be normalized according to the suffix settings of the rule yii\web\UrlNormalizer

公共方法

隐藏继承的方法

方法描述被定义在
__call() Calls the named method which is not a class method. yii\base\BaseObject
__construct() Constructor. yii\base\BaseObject
__get() Returns the value of an object property. yii\base\BaseObject
__isset() Checks if a property is set, i.e. defined and not null. yii\base\BaseObject
__set() Sets value of an object property. yii\base\BaseObject
__unset() Sets an object property to null. yii\base\BaseObject
canGetProperty() Returns a value indicating whether a property can be read. yii\base\BaseObject
canSetProperty() Returns a value indicating whether a property can be set. yii\base\BaseObject
className() Returns the fully qualified name of this class. yii\base\BaseObject
hasMethod() Returns a value indicating whether a method is defined. yii\base\BaseObject
hasProperty() Returns a value indicating whether a property is defined. yii\base\BaseObject
init() Initializes the object. yii\base\BaseObject
normalizePathInfo() Normalizes specified pathInfo. yii\web\UrlNormalizer
normalizeRoute() Performs normalization action for the specified $route. yii\web\UrlNormalizer

受保护的方法

隐藏继承的方法

方法描述被定义在
collapseSlashes() Collapse consecutive slashes in $pathInfo, for example converts site///index into site/index. yii\web\UrlNormalizer
normalizeTrailingSlash() Adds or removes trailing slashes from $pathInfo depending on whether the $suffix has a trailing slash or not. yii\web\UrlNormalizer

常量

隐藏继承的常量

常量描述被定义在
ACTION_NOT_FOUND 404 Represents showing 404 error page during route normalization. yii\web\UrlNormalizer
ACTION_REDIRECT_PERMANENT 301 Represents permament redirection during route normalization. yii\web\UrlNormalizer
ACTION_REDIRECT_TEMPORARY 302 Represents temporary redirection during route normalization. yii\web\UrlNormalizer

属性详情

$action 公共 属性

Action to perform during route normalization. Available options are:

  • null - no special action will be performed
  • 301 - the request should be redirected to the normalized URL using permanent redirection
  • 302 - the request should be redirected to the normalized URL using temporary redirection
  • 404 - yii\web\NotFoundHttpException will be thrown
  • callable - custom user callback, for example:

    function ($route, $normalizer) {
        // use custom action for redirections
        $route[1]['oldRoute'] = $route[0];
        $route[0] = 'site/redirect';
        return $route;
    }
    
public integer|callable|null $action self::ACTION_REDIRECT_PERMANENT
$collapseSlashes 公共 属性

Whether slashes should be collapsed, for example site///index will be converted into site/index

public boolean $collapseSlashes true
$normalizeTrailingSlash 公共 属性

Whether trailing slash should be normalized according to the suffix settings of the rule

方法详情

collapseSlashes() 受保护 方法

Collapse consecutive slashes in $pathInfo, for example converts site///index into site/index.

protected string collapseSlashes($pathInfo)
$pathInfo string

Raw path info.

return string

Normalized path info.

normalizePathInfo() 公共 方法

Normalizes specified pathInfo.

public string normalizePathInfo($pathInfo, $suffix, &$normalized false)
$pathInfo string

PathInfo for normalization

$suffix string

Current rule suffix

$normalized boolean

If specified, this variable will be set to true if $pathInfo was changed during normalization

return string

Normalized pathInfo

normalizeRoute() 公共 方法

Performs normalization action for the specified $route.

public array normalizeRoute($route)
$route array

Route for normalization

return array

Normalized route

throws yii\base\InvalidConfigException

if invalid normalization action is used.

throws yii\web\UrlNormalizerRedirectException

if normalization requires redirection.

throws yii\web\NotFoundHttpException

if normalization suggests action matching route does not exist.

normalizeTrailingSlash() 受保护 方法

Adds or removes trailing slashes from $pathInfo depending on whether the $suffix has a trailing slash or not.

protected string normalizeTrailingSlash($pathInfo, $suffix)
$pathInfo string

Raw path info.

$suffix string
return string

Normalized path info.