sfRouting class controls the creation of URLs and parses URLs. It maps an
array of parameters to URLs definition.
Method Summary
-
appendRoute($name, $route, $default = array(), $requirements = array())
Adds a new route.
-
prependRoute($name, $route, $default = array(), $requirements = array())
Adds a new route at the beginning of the current list of routes.
-
getInstance()
Retrieve the singleton instance of this class.
-
array
parse($url)
Parses a URL to find a matching route.
-
array
connect($name, $route, $default = array(), $requirements = array())
Adds a new route at the end of the current list of routes.
-
string
getCurrentInternalUri($with_route_name = false)
Gets the internal URI for the current request.
-
array
setRoutes($routes)
Sets the compiled route array.
-
boolean
hasRouteName($name)
Returns true if the route name given is defined.
-
clearRoutes()
Clears all current routes.
-
boolean
hasRoutes()
Returns true if this instance has some routes.
-
string
getCurrentRouteName()
Gets the current route name.
-
array
getRouteByName($name)
Gets a route by its name.
-
string
generate($name, $params, $querydiv = '/', $divider = '/', $equals = '/')
Generates a valid URLs for parameters.
-
array
getRoutes()
Gets the current compiled route array.
-
setCurrentRouteName($name)
Sets the current route name.
Method Details
-
appendRoute ($name, $route, $default = array(), $requirements = array())
Adds a new route.
Alias for the connect method.
-
prependRoute ($name, $route, $default = array(), $requirements = array())
Adds a new route at the beginning of the current list of routes.
-
getInstance ()
Retrieve the singleton instance of this class.
returns The sfRouting implementation instance
-
(array) parse ($url)
Parses a URL to find a matching route.
Returns null if no route match the URL.
returns An array of parameters
-
(array) connect ($name, $route, $default = array(), $requirements = array())
| $name |
The route name |
| $route |
The route string |
| $default |
The default parameter values |
| $requirements |
The regexps parameters must match |
Adds a new route at the end of the current list of routes.
A route string is a string with 2 special constructions:
Here is a very common rule in a symfony project:
$r->connect('/:module/:action/*');
returns current routes
-
(string) getCurrentInternalUri ($with_route_name = false)
| $with_route_name |
Whether to give an internal URI with the route name (@route)
or with the module/action pair |
Gets the internal URI for the current request.
returns The current internal URI
-
(array) setRoutes ($routes)
Sets the compiled route array.
returns The route array
-
(boolean) hasRouteName ($name)
Returns true if the route name given is defined.
-
clearRoutes ()
Clears all current routes.
-
(boolean) hasRoutes ()
Returns true if this instance has some routes.
-
(string) getCurrentRouteName ()
Gets the current route name.
returns The route name
-
(array) getRouteByName ($name)
Gets a route by its name.
returns A route array
-
(string) generate ($name, $params, $querydiv = '/', $divider = '/', $equals = '/')
| $name |
The parameter values |
| $params |
The divider between key/value pairs |
| $querydiv |
The equal sign to use between key and value |
Generates a valid URLs for parameters.
returns The generated URL
-
(array) getRoutes ()
Gets the current compiled route array.
returns The route array
-
setCurrentRouteName ($name)
Sets the current route name.
|