Inheritance | yii\web\UrlNormalizer » yii\base\Object |
---|---|
Implements | yii\base\Configurable |
Available since version | 2.0.10 |
Source Code | https://github.com/yiisoft/yii2/blob/master/framework/web/UrlNormalizer.php |
UrlNormalizer normalizes URLs for yii\web\UrlManager and yii\web\UrlRule.
Property | Type | Description | Defined By |
---|---|---|---|
$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 |
Method | Description | Defined By |
---|---|---|
__call() | Calls the named method which is not a class method. | yii\base\Object |
__construct() | Constructor. | yii\base\Object |
__get() | Returns the value of an object property. | yii\base\Object |
__isset() | Checks if a property is set, i.e. defined and not null. | yii\base\Object |
__set() | Sets value of an object property. | yii\base\Object |
__unset() | Sets an object property to null. | yii\base\Object |
canGetProperty() | Returns a value indicating whether a property can be read. | yii\base\Object |
canSetProperty() | Returns a value indicating whether a property can be set. | yii\base\Object |
className() | Returns the fully qualified name of this class. | yii\base\Object |
hasMethod() | Returns a value indicating whether a method is defined. | yii\base\Object |
hasProperty() | Returns a value indicating whether a property is defined. | yii\base\Object |
init() | Initializes the object. | yii\base\Object |
normalizePathInfo() | Normalizes specified pathInfo. | yii\web\UrlNormalizer |
normalizeRoute() | Performs normalization action for the specified $route. | yii\web\UrlNormalizer |
Method | Description | Defined By |
---|---|---|
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 |
Constant | Value | Description | Defined By |
---|---|---|---|
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 to perform during route normalization. Available options are:
null
- no special action will be performed301
- the request should be redirected to the normalized URL using permanent redirection302
- the request should be redirected to the normalized URL using temporary redirection404
- yii\web\NotFoundHttpException will be throwncallable
- 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
Whether slashes should be collapsed, for example site///index
will be converted into site/index
public boolean $collapseSlashes = true
Whether trailing slash should be normalized according to the suffix settings of the rule
public boolean $normalizeTrailingSlash = true
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. |
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 |
return | string |
Normalized pathInfo |
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. |
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. |
© 2008–2017 by Yii Software LLC
Licensed under the three clause BSD license.
http://www.yiiframework.com/doc-2.0/yii-web-urlnormalizer.html