UrlManager

Type
Class
Namespace
Craft
Inherits
Craft\UrlManager » CUrlManager » CApplicationComponent » CComponent
Implements
IApplicationComponent
Since
1.0

Class UrlManager

See also http://craftcms.com

View source

Public Properties

PropertyDescription
$appendParamsboolean – Whether to append GET parameters to the path info part.
$behaviorsarray – The behaviors that should be attached to this component.
$cacheIDstring – The ID of the cache application component that is used to cache the parsed URL rules.
$caseSensitiveboolean – Whether routes are case-sensitive.
$cpRoutes
$matchValueboolean – Whether the GET parameter values should match the corresponding sub-patterns in a rule before using it to create a URL.
$pathParam
$routeVarstring – The GET variable name for route.
$rulesarray – The URL rules (pattern=>route).
$showScriptNameboolean – Whether to show entry script name in the constructed URL.
$urlRuleClassstring – The class name or path alias for the URL rule instances.
$urlSuffixstring – The URL suffix used when in 'path' format.
$useStrictParsingboolean – Whether to enable strict URL parsing.

$cpRoutes

Signature

public  $cpRoutes = null

$pathParam

Signature

public  $pathParam = null

Public Methods

MethodDescription
__call()Calls the named method which is not a class method.
__get()Returns a property value, an event handler list or a behavior based on its name.
__isset()Checks if a property value is null.
__set()Sets value of a component property.
__unset()Sets a component property to be null.
addRules()Adds new URL rules.
asa()Returns the named behavior object.
attachBehavior()Attaches a behavior to this component.
attachBehaviors()Attaches a list of behaviors to the component.
attachEventHandler()Attaches an event handler to an event.
canGetProperty()Determines whether a property can be read.
canSetProperty()Determines whether a property can be set.
createPathInfo()Creates a path info based on the given parameters.
createUrl()Constructs a URL.
detachBehavior()Detaches a behavior from the component.
detachBehaviors()Detaches all behaviors from the component.
detachEventHandler()Detaches an existing event handler.
disableBehavior()Disables an attached behavior.
disableBehaviors()Disables all behaviors attached to this component.
enableBehavior()Enables an attached behavior.
enableBehaviors()Enables all behaviors attached to this component.
evaluateExpression()Evaluates a PHP expression or callback under the context of this component.
getBaseUrl()Returns the base URL of the application.
getEventHandlers()Returns the list of attached event handlers for an event.
getIsInitialized()Checks if this application component has been initialized.
getMatchedElement()Returns the element that was matched by the URI.
getRouteParams()Returns the route params, or null if we haven't parsed the URL yet.
getUrlFormat()Returns the URL format.
hasEvent()Determines whether an event is defined.
hasEventHandler()Checks whether the named event has attached handlers.
hasProperty()Determines whether a property is defined.
init()
parsePathInfo()Parses a path info into URL segments and saves them to $_GET and $_REQUEST.
parseUrl()Determines which controller/action to route the request to. Routing candidates include actual template paths, elements with URIs, and registered URL routes.
raiseEvent()Raises an event.
removeUrlSuffix()Removes the URL suffix from path info.
setBaseUrl()Sets the base URL of the application (the part after host name and before query string).
setRouteVariables()Sets variables to be passed to the routed controllers action's $variables argument.
setUrlFormat()Sets the URL format.

getMatchedElement()

Returns the element that was matched by the URI.

View source

Returns

Craft\BaseElementModel, false

Signature

public Craft\BaseElementModel, false getMatchedElement ( )

getRouteParams()

Returns the route params, or null if we haven't parsed the URL yet.

View source

Returns

array, null

Signature

public array, null getRouteParams ( )

init()

Signature

public null init ( )

parseUrl()

Determines which controller/action to route the request to. Routing candidates include actual template paths, elements with URIs, and registered URL routes.

View source

Arguments

Returns

string – The controller/action path.

Throws

  • Craft\HttpException
    Throws a 404 in the event that we can't figure out where to route the request.

Signature

public string parseUrl ( $request )

setRouteVariables()

Sets variables to be passed to the routed controllers action's $variables argument.

View source

Arguments

Returns

null

Signature

public null setRouteVariables ( $variables )

Protected Methods

MethodDescription
createUrlDefault()Creates a URL based on default settings.
createUrlRule()Creates a URL rule instance.
processRules()Processes the URL rules.

Constants

ConstantDescription
CACHE_KEY
GET_FORMAT
PATH_FORMAT