Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Expand doc block for Router::connect().

  • Loading branch information...
commit 9c9cc7fba2f80f00a851de7d82767428246258d6 1 parent 2a8ebce
@markstory markstory authored
Showing with 19 additions and 9 deletions.
  1. +19 −9 lib/Cake/Routing/Router.php
View
28 lib/Cake/Routing/Router.php
@@ -259,18 +259,28 @@ public static function resourceMap($resourceMap = null) {
* $options offers four 'special' keys. `pass`, `named`, `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')`
+ * - `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'`
+ * - `named` is used to configure named parameters at the route level. This key uses the same options
+ * as Router::connectNamed()
*
- * `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')`
+ * In addition to the 4 keys listed above, you can add additional conditions for matching routes.
+ * The following conditions can be used:
*
- * `routeClass` is used to extend and change how individual routes parse requests and handle reverse routing,
- * via a custom routing class. Ex. `'routeClass' => 'SlugRoute'`
+ * - `[type]` Only match requests for specific content types.
@ADmad Collaborator
ADmad added a note

I noticed there are no test cases for [type] and [server].

@markstory Owner

Nope, probably should add some.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ * - `[method]` Only match requests with specific HTTP verbs.
+ * - `[server]` Only match when $_SERVER['SERVER_NAME'] matches the given value.
*
- * `named` is used to configure named parameters at the route level. This key uses the same options
- * as Router::connectNamed()
+ * Example of using the `[method]` condition:
+ *
+ * `Router::connect('/tasks', array('controller' => 'tasks', 'action' => 'index'), array('[method]' => 'GET'));`
+ *
+ * The above route will only be matched for GET requests. POST requests will fail to match this route.
*
* @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
Please sign in to comment.
Something went wrong with that request. Please try again.