UrlManager

Type
Class
Namespace
Craft
Inherits
Craft\UrlManager » CUrlManager (opens new window) » CApplicationComponent (opens new window) » CComponent (opens new window)
Implements
IApplicationComponent
Since
1.0

Class UrlManager

See also http://craftcms.com

View source (opens new window)

# Public Properties

Property Description
$appendParams (opens new window) boolean (opens new window) – Whether to append GET parameters to the path info part.
$behaviors (opens new window) array (opens new window) – The behaviors that should be attached to this component.
$cacheID (opens new window) string (opens new window) – The ID of the cache application component that is used to cache the parsed URL rules.
$caseSensitive (opens new window) boolean (opens new window) – Whether routes are case-sensitive.
$cpRoutes
$matchValue (opens new window) boolean (opens new window) – Whether the GET parameter values should match the corresponding sub-patterns in a rule before using it to create a URL.
$pathParam
$routeVar (opens new window) string (opens new window) – The GET variable name for route.
$rules (opens new window) array (opens new window) – The URL rules (pattern=>route).
$showScriptName (opens new window) boolean (opens new window) – Whether to show entry script name in the constructed URL.
$urlRuleClass (opens new window) string (opens new window) – The class name or path alias for the URL rule instances.
$urlSuffix (opens new window) string (opens new window) – The URL suffix used when in 'path' format.
$useStrictParsing (opens new window) boolean (opens new window) – Whether to enable strict URL parsing.

# $cpRoutes

Signature

public  $cpRoutes = null

# $pathParam

Signature

public  $pathParam = null

# Public Methods

Method Description
__call() (opens new window) Calls the named method which is not a class method.
__get() (opens new window) Returns a property value, an event handler list or a behavior based on its name.
__isset() (opens new window) Checks if a property value is null.
__set() (opens new window) Sets value of a component property.
__unset() (opens new window) Sets a component property to be null.
addRules() (opens new window) Adds new URL rules.
asa() (opens new window) Returns the named behavior object.
attachBehavior() (opens new window) Attaches a behavior to this component.
attachBehaviors() (opens new window) Attaches a list of behaviors to the component.
attachEventHandler() (opens new window) Attaches an event handler to an event.
canGetProperty() (opens new window) Determines whether a property can be read.
canSetProperty() (opens new window) Determines whether a property can be set.
createPathInfo() (opens new window) Creates a path info based on the given parameters.
createUrl() (opens new window) Constructs a URL.
detachBehavior() (opens new window) Detaches a behavior from the component.
detachBehaviors() (opens new window) Detaches all behaviors from the component.
detachEventHandler() (opens new window) Detaches an existing event handler.
disableBehavior() (opens new window) Disables an attached behavior.
disableBehaviors() (opens new window) Disables all behaviors attached to this component.
enableBehavior() (opens new window) Enables an attached behavior.
enableBehaviors() (opens new window) Enables all behaviors attached to this component.
evaluateExpression() (opens new window) Evaluates a PHP expression or callback under the context of this component.
getBaseUrl() (opens new window) Returns the base URL of the application.
getEventHandlers() (opens new window) Returns the list of attached event handlers for an event.
getIsInitialized() (opens new window) 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() (opens new window) Returns the URL format.
hasEvent() (opens new window) Determines whether an event is defined.
hasEventHandler() (opens new window) Checks whether the named event has attached handlers.
hasProperty() (opens new window) Determines whether a property is defined.
init()
parsePathInfo() (opens new window) 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() (opens new window) Raises an event.
removeUrlSuffix() (opens new window) Removes the URL suffix from path info.
setBaseUrl() (opens new window) 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() (opens new window) Sets the URL format.

# getMatchedElement()

Returns the element that was matched by the URI.

View source (opens new window)

Returns

Craft\BaseElementModel, false (opens new window)

Signature

public Craft\BaseElementModel, false getMatchedElement ( )

# getRouteParams()

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

View source (opens new window)

Returns

array (opens new window), null (opens new window)

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 (opens new window)

Arguments

Returns

string (opens new window) – 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 (opens new window)

Arguments

Returns

null (opens new window)

Signature

public null setRouteVariables ( $variables )

# Protected Methods

Method Description
createUrlDefault() (opens new window) Creates a URL based on default settings.
createUrlRule() (opens new window) Creates a URL rule instance.
processRules() (opens new window) Processes the URL rules.

# Constants

Constant Description
CACHE_KEY
GET_FORMAT
PATH_FORMAT