|
|
@ -13,6 +13,11 @@ use yii\base\Object; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* UrlManager manages the URLs of Yii applications. |
|
|
|
* UrlManager manages the URLs of Yii applications. |
|
|
|
|
|
|
|
* array( |
|
|
|
|
|
|
|
* 'pattern' => 'post/<id:\d+>', |
|
|
|
|
|
|
|
* 'route' => 'post/view', |
|
|
|
|
|
|
|
* 'params' => array('id' => 1), |
|
|
|
|
|
|
|
* ) |
|
|
|
* |
|
|
|
* |
|
|
|
* @author Qiang Xue <qiang.xue@gmail.com> |
|
|
|
* @author Qiang Xue <qiang.xue@gmail.com> |
|
|
|
* @since 2.0 |
|
|
|
* @since 2.0 |
|
|
@ -20,76 +25,29 @@ use yii\base\Object; |
|
|
|
class UrlRule extends Object |
|
|
|
class UrlRule extends Object |
|
|
|
{ |
|
|
|
{ |
|
|
|
/** |
|
|
|
/** |
|
|
|
* @var string the URL suffix used for this rule. |
|
|
|
* @var string regular expression used to parse a URL |
|
|
|
* For example, ".html" can be used so that the URL looks like pointing to a static HTML page. |
|
|
|
|
|
|
|
* Defaults to null, meaning using the value of {@link CUrlManager::urlSuffix}. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public $urlSuffix; |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @var boolean whether the rule is case sensitive. Defaults to null, meaning |
|
|
|
|
|
|
|
* using the value of {@link CUrlManager::caseSensitive}. |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public $caseSensitive; |
|
|
|
public $pattern; |
|
|
|
/** |
|
|
|
/** |
|
|
|
* @var array the default GET parameters (name=>value) that this rule provides. |
|
|
|
* @var array the default GET parameters (name=>value) that this rule provides. |
|
|
|
* When this rule is used to parse the incoming request, the values declared in this property |
|
|
|
* When this rule is used to parse the incoming request, the values declared in this property |
|
|
|
* will be injected into $_GET. |
|
|
|
* will be injected into $_GET. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public $defaultParams = array(); |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @var boolean whether the GET parameter values should match the corresponding |
|
|
|
|
|
|
|
* sub-patterns in the rule when creating a URL. Defaults to null, meaning using the value |
|
|
|
|
|
|
|
* of {@link CUrlManager::matchValue}. When this property is false, it means |
|
|
|
|
|
|
|
* a rule will be used for creating a URL if its route and parameter names match the given ones. |
|
|
|
|
|
|
|
* If this property is set true, then the given parameter values must also match the corresponding |
|
|
|
|
|
|
|
* parameter sub-patterns. Note that setting this property to true will degrade performance. |
|
|
|
|
|
|
|
* @since 1.1.0 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public $matchValue; |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @var string the HTTP verb (e.g. GET, POST, DELETE) that this rule should match. |
|
|
|
|
|
|
|
* If this rule can match multiple verbs, please separate them with commas. |
|
|
|
|
|
|
|
* If this property is not set, the rule can match any verb. |
|
|
|
|
|
|
|
* Note that this property is only used when parsing a request. It is ignored for URL creation. |
|
|
|
|
|
|
|
* @since 1.1.7 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public $verb; |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @var boolean whether this rule is only used for request parsing. |
|
|
|
|
|
|
|
* Defaults to false, meaning the rule is used for both URL parsing and creation. |
|
|
|
|
|
|
|
* @since 1.1.7 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public $parsingOnly = false; |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @var string the controller/action pair |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public $route; |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @var array the mapping from route param name to token name (e.g. _r1=><1>) |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public $references = array(); |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @var string the pattern used to match route |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public $routePattern; |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @var string regular expression used to parse a URL |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public $pattern; |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @var string template used to construct a URL |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public $template; |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @var array list of parameters (name=>regular expression) |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public $params = array(); |
|
|
|
public $params = array(); |
|
|
|
/** |
|
|
|
/** |
|
|
|
* @var boolean whether the URL allows additional parameters at the end of the path info. |
|
|
|
* @var string the route to the controller action |
|
|
|
*/ |
|
|
|
|
|
|
|
public $append; |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @var boolean whether host info should be considered for this rule |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public $hasHostInfo; |
|
|
|
public $route; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function createUrl($route, $params, $ampersand) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function parse($path) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$route = ''; |
|
|
|
|
|
|
|
$params = array(); |
|
|
|
|
|
|
|
return array($route, $params); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|