system system.base system.caching system.caching.dependencies system.collections system.console system.db system.db.ar system.db.schema system.db.schema.mssql system.db.schema.mysql system.db.schema.oci system.db.schema.pgsql system.db.schema.sqlite system.i18n system.i18n.gettext system.logging system.utils system.validators system.web system.web.actions system.web.auth system.web.filters system.web.helpers system.web.renderers system.web.services system.web.widgets system.web.widgets.captcha system.web.widgets.pagers

CUrlRule

system.web
继承 class CUrlRule » CComponent
可用自 1.0
版本 $Id$
CUrlRule represents a URL formatting/parsing rule.

It mainly consists of two parts: route and pattern. The former classifies the rule so that it only applies to specific controller-action route. The latter performs the actual formatting and parsing role. The pattern may have a set of named parameters.

公共属性

隐藏继承的属性

属性类型描述被定义在
append boolean whether the URL allows additional parameters at the end of the path info. CUrlRule
caseSensitive boolean whether the rule is case sensitive. CUrlRule
defaultParams array the default GET parameters (name=>value) that this rule provides. CUrlRule
hasHostInfo boolean whether host info should be considered for this rule CUrlRule
params array list of parameters (name=>regular expression) CUrlRule
pattern string regular expression used to parse a URL CUrlRule
references array the mapping from route param name to token name (e. CUrlRule
route string the controller/action pair CUrlRule
routePattern string the pattern used to match route CUrlRule
template string template used to construct a URL CUrlRule
urlSuffix string the URL suffix used for this rule. CUrlRule

公共方法

隐藏继承的方法

方法描述被定义在
__call() Calls the named method which is not a class method. CComponent
__construct() Constructor. CUrlRule
__get() Returns a property value, an event handler list or a behavior based on its name. CComponent
__isset() Checks if a property value is null. CComponent
__set() Sets value of a component property. CComponent
__unset() Sets a component property to be null. CComponent
asa() Returns the named behavior object. CComponent
attachBehavior() Attaches a behavior to this component. CComponent
attachBehaviors() Attaches a list of behaviors to the component. CComponent
attachEventHandler() Attaches an event handler to an event. CComponent
canGetProperty() Determines whether a property can be read. CComponent
canSetProperty() Determines whether a property can be set. CComponent
createUrl() Creates a URL based on this rule. CUrlRule
detachBehavior() Detaches a behavior from the component. CComponent
detachBehaviors() Detaches all behaviors from the component. CComponent
detachEventHandler() Detaches an existing event handler. CComponent
disableBehavior() Disables an attached behavior. CComponent
disableBehaviors() Disables all behaviors attached to this component. CComponent
enableBehavior() Enables an attached behavior. CComponent
enableBehaviors() Enables all behaviors attached to this component. CComponent
getEventHandlers() Returns the list of attached event handlers for an event. CComponent
hasEvent() Determines whether an event is defined. CComponent
hasEventHandler() Checks whether the named event has attached handlers. CComponent
hasProperty() Determines whether a property is defined. CComponent
parseUrl() Parases a URL based on this rule. CUrlRule
raiseEvent() Raises an event. CComponent

属性详情

append 属性
public boolean $append;

whether the URL allows additional parameters at the end of the path info.

caseSensitive 属性 (自版本 v1.0.1 可用)
public boolean $caseSensitive;

whether the rule is case sensitive. Defaults to null, meaning using the value of CUrlManager::caseSensitive.

defaultParams 属性 (自版本 v1.0.8 可用)
public array $defaultParams;

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 will be injected into $_GET.

hasHostInfo 属性 (自版本 v1.0.11 可用)
public boolean $hasHostInfo;

whether host info should be considered for this rule

params 属性
public array $params;

list of parameters (name=>regular expression)

pattern 属性
public string $pattern;

regular expression used to parse a URL

references 属性 (自版本 v1.0.5 可用)
public array $references;

the mapping from route param name to token name (e.g. _r1=><1>)

route 属性
public string $route;

the controller/action pair

routePattern 属性 (自版本 v1.0.5 可用)
public string $routePattern;

the pattern used to match route

template 属性
public string $template;

template used to construct a URL

urlSuffix 属性 (自版本 v1.0.6 可用)
public string $urlSuffix;

the URL suffix used for this rule. 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 CUrlManager::urlSuffix.

方法详情

__construct() 方法
public void __construct(string $route, string $pattern)
$route string the route of the URL (controller/action)
$pattern string the pattern for matching the URL

Constructor.

createUrl() 方法
public string createUrl(CUrlManager $manager, string $route, array $params, string $ampersand)
$manager CUrlManager the manager
$route string the route
$params array list of parameters
$ampersand string the token separating name-value pairs in the URL.
{return} string the constructed URL

Creates a URL based on this rule.

parseUrl() 方法
public string parseUrl(CUrlManager $manager, CHttpRequest $request, string $pathInfo, string $rawPathInfo)
$manager CUrlManager the URL manager
$request CHttpRequest the request object
$pathInfo string path info part of the URL
$rawPathInfo string path info that contains the potential URL suffix
{return} string the route that consists of the controller ID and action ID

Parases a URL based on this rule.