Inheritance diagram for Router:

Public Member Functions | |
| __connectDefaultRoutes () | |
| __mapRoute ($route, $params=array()) | |
| __matchRoute ($route, $url) | |
| __parseExtension ($url) | |
| compile ($i) | |
| matchNamed ($param, $val, $rule, $context=array()) | |
| normalize ($url= '/') | |
Static Public Member Functions | |
| connect ($route, $default=array(), $params=array()) | |
| connectNamed ($named, $options=array()) | |
| currentRoute () | |
| getArgs ($args, $options=array()) | |
| & | getInstance () |
| getNamedElements ($params, $controller=null, $action=null) | |
| getNamedExpressions () | |
| getParam ($name= 'controller', $current=false) | |
| getParams ($current=false) | |
| getPaths ($current=false) | |
| mapResources ($controller, $options=array()) | |
| mapRouteElements ($route, $url) | |
| parse ($url) | |
| parseExtensions () | |
| prefixes () | |
| promote ($which=null) | |
| queryString ($q, $extra=array(), $escape=false) | |
| reload () | |
| requestRoute () | |
| setRequestInfo ($params) | |
| stripEscape ($param) | |
| stripPlugin ($base, $plugin=null) | |
| url ($url=null, $full=false) | |
| writeRoute ($route, $default, $params) | |
Public Attributes | |
| $__admin = null | |
| $__currentRoute = array() | |
| $__defaultsMapped = false | |
| $__headerMap | |
| $__named | |
| $__params = array() | |
| $__parseExtensions = false | |
| $__paths = array() | |
| $__prefixes = array() | |
| $__resourceMap | |
| $__resourceMapped = array() | |
| $__validExtensions = null | |
| $named | |
| $routes = array() | |
Definition at line 40 of file router.php.
| Router::__connectDefaultRoutes | ( | ) |
Connects the default, built-in routes, including admin routes, and (deprecated) web services routes.
Definition at line 582 of file router.php.
References connect(), Configure::listObjects(), and underscore().
| Router::__mapRoute | ( | $ | route, | |
| $ | params = array() | |||
| ) |
Merges URL parameters into a route string
| array | $route Route | |
| array | $params Parameters |
Definition at line 1044 of file router.php.
| Router::__matchRoute | ( | $ | route, | |
| $ | url | |||
| ) |
Checks to see if the given URL matches the given route
| array | $route | |
| string | $url |
Definition at line 495 of file router.php.
Referenced by parse().
| Router::__parseExtension | ( | $ | url | ) |
Parses a file extension out of a URL, if Router::parseExtensions() is enabled.
| string | $url |
Definition at line 551 of file router.php.
References $url, a(), ext(), and url().
Referenced by parse().
| Router::compile | ( | $ | i | ) |
Compiles a route by numeric key and returns the compiled expression, replacing the existing uncompiled route. Do not call statically.
| integer | $i |
Definition at line 533 of file router.php.
References writeRoute().
| Router::connect | ( | $ | route, | |
| $ | default = array(), |
|||
| $ | params = array() | |||
| ) | [static] |
Returns this object's routes array. Returns false if there are no routes available.
| string | $route An empty string, or a route string "/" | |
| array | $default NULL or an array describing the default route | |
| array | $params An array matching the named elements in the route to regular expressions which that element should match. |
Definition at line 201 of file router.php.
References getInstance().
Referenced by __connectDefaultRoutes(), and mapResources().
| Router::connectNamed | ( | $ | named, | |
| $ | options = array() | |||
| ) | [static] |
Specifies what named parameters CakePHP should be parsing. The most common setups are:
Do not parse any named parameters: {{{ Router::connectNamed(false); }}}
Parse only default parameters used for CakePHP's pagination: {{{ Router::connectNamed(false, array('default' => true)); }}}
Parse only the page parameter if its value is a number: {{{ Router::connectNamed(array('page' => '[]+'), array('default' => false, 'greedy' => false)); }}}
Parse only the page parameter no mater what. {{{ Router::connectNamed(array('page'), array('default' => false, 'greedy' => false)); }}}
Parse only the page parameter if the current action is 'index'. {{{ Router::connectNamed(array('page' => array('action' => 'index')), array('default' => false, 'greedy' => false)); }}}
Parse only the page parameter if the current action is 'index' and the controller is 'pages'. {{{ Router::connectNamed(array('page' => array('action' => 'index', 'controller' => 'pages')), array('default' => false, 'greedy' => false)); }}}
| array | $named A list of named parameters. Key value pairs are accepted where values are either regex strings to match, or arrays as seen above. | |
| array | $options Allows to control all settings: separator, greedy, reset, default |
Definition at line 244 of file router.php.
References getInstance().
| Router::currentRoute | ( | ) | [static] |
Returns the route matching the current request (useful for requestAction traces)
Definition at line 1230 of file router.php.
| Router::getArgs | ( | $ | args, | |
| $ | options = array() | |||
| ) | [static] |
Takes an passed params and converts it to args
| array | $params |
Definition at line 1316 of file router.php.
Referenced by Dispatcher::_restructureParams(), and parse().
| & Router::getInstance | ( | ) | [static] |
Gets a reference to the Router object instance
Definition at line 169 of file router.php.
References Configure::read().
Referenced by ConsoleShell::__loadRoutes(), connect(), connectNamed(), getNamedExpressions(), ConsoleShell::main(), mapResources(), parse(), and prefixes().
| Router::getNamedElements | ( | $ | params, | |
| $ | controller = null, |
|||
| $ | action = null | |||
| ) | [static] |
Takes an array of URL parameters and separates the ones that can be used as named arguments
| array | $params Associative array of URL parameters. | |
| string | $controller Name of controller being routed. Used in scoping. | |
| string | $action Name of action being routed. Used in scoping. |
Definition at line 1102 of file router.php.
| Router::getNamedExpressions | ( | ) | [static] |
Gets the named route elements for use in app/config/routes.php
Definition at line 186 of file router.php.
References getInstance().
Referenced by Dispatcher::parseParams().
| Router::getParam | ( | $ | name = 'controller', |
|
| $ | current = false | |||
| ) | [static] |
Gets URL parameter by name
| string | $name Parameter name | |
| boolean | $current Current parameter |
Definition at line 667 of file router.php.
| Router::getParams | ( | $ | current = false |
) | [static] |
Gets parameter information
| boolean | $current Get current parameter (true) |
Definition at line 648 of file router.php.
Referenced by CakeErrorController::__construct().
| Router::getPaths | ( | $ | current = false |
) | [static] |
Gets path information
| boolean | $current Current parameter |
Definition at line 682 of file router.php.
Referenced by CakeErrorController::__construct().
| Router::mapResources | ( | $ | controller, | |
| $ | options = array() | |||
| ) | [static] |
Creates REST resource routes for the given controller(s)
Options:
| mixed | $controller A controller name or array of controller names (i.e. "Posts" or "ListItems") | |
| array | $options Options to use when generating REST routes |
Definition at line 291 of file router.php.
References $id, $url, connect(), getInstance(), and underscore().
| Router::mapRouteElements | ( | $ | route, | |
| $ | url | |||
| ) | [static] |
Maps a URL array onto a route and returns the string result, or false if no match
| array | $route Route Route | |
| array | $url URL URL to map |
Definition at line 941 of file router.php.
| Router::matchNamed | ( | $ | param, | |
| $ | val, | |||
| $ | rule, | |||
| $ | context = array() | |||
| ) |
Return true if a given named $param's $val matches a given $rule depending on $context. Currently implemented rule types are controller, action and match that can be combined with each other.
| string | $param The name of the named parameter | |
| string | $val The value of the named parameter | |
| array | $rule The rule(s) to apply, can also be a match string | |
| string | $context An array with additional context information (controller / action) |
Definition at line 1128 of file router.php.
| Router::normalize | ( | $ | url = '/' |
) |
Normalizes a URL for purposes of comparison
| mixed | $url URL to normalize |
Definition at line 1189 of file router.php.
Referenced by AuthComponent::__setDefaults(), ErrorHandler::error404(), AuthComponent::logout(), AuthComponent::redirect(), and AuthComponent::startup().
| Router::parse | ( | $ | url | ) | [static] |
Parses given URL and returns an array of controllers, action and parameters taken from that URL.
| string | $url URL to be parsed |
Definition at line 403 of file router.php.
References $out, $url, __matchRoute(), __parseExtension(), a(), ext(), getArgs(), getInstance(), stripslashes_deep(), and url().
Referenced by ConsoleShell::main(), and Dispatcher::parseParams().
| Router::parseExtensions | ( | ) | [static] |
Instructs the router to parse out file extensions from the URL. For example, http://example.com/posts.rss would yield an file extension of "rss". The file extension itself is made available in the controller as $this->params['url']['ext'], and is used by the RequestHandler component to automatically switch to alternate layouts and templates, and load helpers corresponding to the given content, i.e. RssHelper.
A list of valid extension can be passed to this method, i.e. Router::parseExtensions('rss', 'xml'); If no parameters are given, anything after the first . (dot) after the last / in the URL will be parsed, excluding querystring parameters (i.e. ?q=...).
public
Definition at line 1301 of file router.php.
| Router::prefixes | ( | ) | [static] |
Returns the list of prefixes used in connected routes
Definition at line 390 of file router.php.
References getInstance().
Referenced by Dispatcher::dispatch().
| Router::promote | ( | $ | which = null |
) | [static] |
Promote a route (by default, the last one added) to the beginning of the list
| $which | A zero-based array index representing the route to move. For example, if 3 routes have been added, the last route would be 2. |
Definition at line 715 of file router.php.
| Router::queryString | ( | $ | q, | |
| $ | extra = array(), |
|||
| $ | escape = false | |||
| ) | [static] |
Generates a well-formed querystring from $q
| mixed | $q Query string | |
| array | $extra Extra querystring parameters. | |
| bool | $escape Whether or not to use escaped & |
Definition at line 1160 of file router.php.
Referenced by AuthComponent::startup().
| Router::reload | ( | ) | [static] |
| Router::requestRoute | ( | ) | [static] |
Returns the route matching the current request URL.
Definition at line 1219 of file router.php.
| Router::setRequestInfo | ( | $ | params | ) | [static] |
Takes parameter and path information back from the Dispatcher
| array | $params Parameters and path information |
Definition at line 625 of file router.php.
Referenced by CacheHelper::__writeFile(), and Dispatcher::dispatch().
| Router::stripEscape | ( | $ | param | ) | [static] |
Strip escape characters from parameter values.
| mixed | $param Either an array, or a string |
Definition at line 1264 of file router.php.
Referenced by Dispatcher::parseParams().
| Router::stripPlugin | ( | $ | base, | |
| $ | plugin = null | |||
| ) | [static] |
Removes the plugin name from the base URL.
| string | $base Base URL | |
| string | $plugin Plugin name |
Definition at line 1243 of file router.php.
| Router::url | ( | $ | url = null, |
|
| $ | full = false | |||
| ) | [static] |
Finds URL for specified action.
Returns an URL pointing to a combination of controller and action. Param $url can be:
| mixed | $url Cake-relative URL, like "/products/edit/92" or "/presidents/elect/4" or an array specifying any of the following: 'controller', 'action', and/or 'plugin', in addition to named arguments (keyed array elements), and standard URL arguments (indexed array elements) | |
| mixed | $full If (bool) true, the full base URL will be prepended to the result. If an array accepts the following keys
|
Definition at line 750 of file router.php.
Referenced by Dispatcher::__extractParams(), __parseExtension(), Controller::flash(), JsHelper::load_(), parse(), Controller::redirect(), Helper::url(), and View::uuid().
| Router::writeRoute | ( | $ | route, | |
| $ | default, | |||
| $ | params | |||
| ) | [static] |
Builds a route regular expression
| string | $route An empty string, or a route string "/" | |
| array | $default NULL or an array describing the default route | |
| array | $params An array matching the named elements in the route to regular expressions which that element should match. |
Definition at line 322 of file router.php.
References a().
Referenced by compile().
| Router::$__admin = null |
Definition at line 54 of file router.php.
| Router::$__currentRoute = array() |
Definition at line 108 of file router.php.
| Router::$__defaultsMapped = false |
Definition at line 161 of file router.php.
| Router::$__headerMap |
Initial value:
array(
'type' => 'content_type',
'method' => 'request_method',
'server' => 'server_name'
)
Definition at line 115 of file router.php.
| Router::$__named |
Initial value:
array(
'Action' => 'index|show|add|create|edit|update|remove|del|delete|view|item',
'Year' => '[12][0-9]{3}',
'Month' => '0[1-9]|1[012]',
'Day' => '0[1-9]|[12][0-9]|3[01]',
'ID' => '[0-9]+',
'UUID' => '[A-Fa-f0-9]{8}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{12}'
)
Definition at line 82 of file router.php.
| Router::$__params = array() |
Definition at line 147 of file router.php.
| Router::$__parseExtensions = false |
Definition at line 68 of file router.php.
| Router::$__paths = array() |
Definition at line 154 of file router.php.
| Router::$__prefixes = array() |
Definition at line 61 of file router.php.
| Router::$__resourceMap |
Initial value:
array(
array('action' => 'index', 'method' => 'GET', 'id' => false),
array('action' => 'view', 'method' => 'GET', 'id' => true),
array('action' => 'add', 'method' => 'POST', 'id' => false),
array('action' => 'edit', 'method' => 'PUT', 'id' => true),
array('action' => 'delete', 'method' => 'DELETE', 'id' => true),
array('action' => 'edit', 'method' => 'POST', 'id' => true)
)
Definition at line 126 of file router.php.
| Router::$__resourceMapped = array() |
Definition at line 140 of file router.php.
| Router::$__validExtensions = null |
Definition at line 75 of file router.php.
| Router::$named |
Initial value:
array(
'default' => array('page', 'fields', 'order', 'limit', 'recursive', 'sort', 'direction', 'step'),
'greedy' => true,
'separator' => ':',
'rules' => false,
)
Definition at line 96 of file router.php.
| Router::$routes = array() |
Definition at line 47 of file router.php.
1.4.7