cakephp-1.3 > Router :: connect()
Router
- __connectDefaultRoutes
- __parseExtension
- __setPrefixes
- _handleNoRoute
- ¤tRoute
- &getInstance
- &requestRoute
- connect
- connectNamed
- defaults
- getArgs
- getNamedElements
- getNamedExpressions
- getParam
- getParams
- getPaths
- mapResources
- matchNamed
- normalize
- parse
- parseExtensions
- prefixes
- promote
- queryString
- reload
- reverse
- Router
- setRequestInfo
- stripPlugin
- url
A
AclBase
AclBehavior
AclComponent
AclNode
AclShell
Aco
AcoAction
AjaxHelper
ApcEngine
ApiShell
App
AppController
AppController
AppHelper
AppHelper
AppModel
AppModel
Aro
AuthComponent
B
BakeShell
BakeTask
BehaviorCollection
C
Cache
CacheEngine
CacheHelper
CakeErrorController
CakeLog
CakeRoute
CakeSchema
CakeSession
CakeSocket
ClassRegistry
Component
Configure
ConnectionManager
ConsoleShell
ContainableBehavior
Controller
ControllerTask
CookieComponent
D
DataSource
DbAcl
DbAclSchema
DbConfigTask
DboMssql
DboMysql
DboMysqlBase
DboMysqli
DboOracle
DboPostgres
DboSource
DboSqlite
Debugger
Dispatcher
E
EmailComponent
ErrorHandler
ErrorHandler
ExtractTask
F
File
FileEngine
FileLog
FixtureTask
Folder
FormHelper
H
Helper
HtmlHelper
HttpSocket
I
I18n
I18nModel
i18nSchema
I18nShell
Inflector
IniAcl
J
JavascriptHelper
JqueryEngineHelper
JsBaseEngineHelper
JsHelper
L
L10n
M
MagicDb
MagicFileResource
MediaView
MemcacheEngine
Model
ModelBehavior
ModelTask
MootoolsEngineHelper
Multibyte
N
NumberHelper
O
Object
Overloadable
Overloadable
Overloadable2
Overloadable2
P
PagesController
PagesController
PaginatorHelper
Permission
PluginShortRoute
PluginTask
ProjectTask
PrototypeEngineHelper
R
RequestHandlerComponent
Router
RssHelper
S
Sanitize
Scaffold
ScaffoldView
SchemaShell
Security
SecurityComponent
SessionComponent
SessionHelper
SessionsSchema
Set
Shell
ShellDispatcher
String
T
TemplateTask
TestSuiteShell
TestTask
TextHelper
ThemeView
TimeHelper
TranslateBehavior
TreeBehavior
V
Validation
View
ViewTask
X
XcacheEngine
Xml
XmlElement
XmlHelper
XmlManager
XmlNode
XmlTextNode
connect
line:263 at
/cake/libs/router.php
Connects a new Route in the router.
Method
(array)
connect
($route, $defaults = array(), $options = array())
Parameters
Parameter | Type | Comment | Default |
---|---|---|---|
$route | string | required A string describing the template of the route | |
$defaults | array | optional An array describing the default route parameters. These parameters will be used by default and can supply routing parameters that are not dynamic. See above. | array() |
$options | array | optional An array matching the named elements in the route to regular expressions which that element should match. Also contains additional parameters such as which routed parameters should be shifted into the passed arguments, supplying patterns for routing parameters and supplying the name of a custom routing class. | array() |
Return
arrayComment
Connects a new Route in the router.
Routes are a way of connecting request urls to objects in your application. At their core routes
are a set or regular expressions that are used to match requests to destinations.
Examples:
`Router::connect('/:controller/:action/*');`
The first parameter will be used as a controller name while the second is used as the action name.
the '/*' syntax makes this route greedy in that it will match requests like `/posts/index` as well as requests
like `/posts/edit/1/foo/bar`.
`Router::connect('/home-page', array('controller' => 'pages', 'action' => 'display', 'home'));`
The above shows the use of route parameter defaults. And providing routing parameters for a static route.
{{{
Router::connect(
'/:lang/:controller/:action/:id',
array(),
array('id' => '[0-9]+', 'lang' => '[a-z]{3}')
);
}}}
Shows connecting a route with custom route parameters as well as providing patterns for those parameters.
Patterns for routing parameters do not need capturing groups, as one will be added for each route params.
$options offers three 'special' keys. `pass`, `persist` and `routeClass` have special meaning in the $options array.
`pass` is used to define which of the routed parameters should be shifted into the pass array. Adding a
parameter to pass will remove it from the regular route array. Ex. `'pass' => array('slug')`
`persist` is used to define which route parameters should be automatically included when generating
new urls. You can override persistent parameters by redefining them in a url or remove them by
setting the parameter to `false`. Ex. `'persist' => array('lang')`
`routeClass` is used to extend and change how individual routes parse requests and handle reverse routing,
via a custom routing class. Ex. `'routeClass' => 'SlugRoute'`
@param string $route A string describing the template of the route
@param array $defaults An array describing the default route parameters. These parameters will be used by default
and can supply routing parameters that are not dynamic. See above.
@param array $options An array matching the named elements in the route to regular expressions which that
element should match. Also contains additional parameters such as which routed parameters should be
shifted into the passed arguments, supplying patterns for routing parameters and supplying the name of a
custom routing class.
@see routes
@return array Array of routes
@access public
@static
Routes are a way of connecting request urls to objects in your application. At their core routes
are a set or regular expressions that are used to match requests to destinations.
Examples:
`Router::connect('/:controller/:action/*');`
The first parameter will be used as a controller name while the second is used as the action name.
the '/*' syntax makes this route greedy in that it will match requests like `/posts/index` as well as requests
like `/posts/edit/1/foo/bar`.
`Router::connect('/home-page', array('controller' => 'pages', 'action' => 'display', 'home'));`
The above shows the use of route parameter defaults. And providing routing parameters for a static route.
{{{
Router::connect(
'/:lang/:controller/:action/:id',
array(),
array('id' => '[0-9]+', 'lang' => '[a-z]{3}')
);
}}}
Shows connecting a route with custom route parameters as well as providing patterns for those parameters.
Patterns for routing parameters do not need capturing groups, as one will be added for each route params.
$options offers three 'special' keys. `pass`, `persist` and `routeClass` have special meaning in the $options array.
`pass` is used to define which of the routed parameters should be shifted into the pass array. Adding a
parameter to pass will remove it from the regular route array. Ex. `'pass' => array('slug')`
`persist` is used to define which route parameters should be automatically included when generating
new urls. You can override persistent parameters by redefining them in a url or remove them by
setting the parameter to `false`. Ex. `'persist' => array('lang')`
`routeClass` is used to extend and change how individual routes parse requests and handle reverse routing,
via a custom routing class. Ex. `'routeClass' => 'SlugRoute'`
@param string $route A string describing the template of the route
@param array $defaults An array describing the default route parameters. These parameters will be used by default
and can supply routing parameters that are not dynamic. See above.
@param array $options An array matching the named elements in the route to regular expressions which that
element should match. Also contains additional parameters such as which routed parameters should be
shifted into the passed arguments, supplying patterns for routing parameters and supplying the name of a
custom routing class.
@see routes
@return array Array of routes
@access public
@static