83 $this->routes =
array();
108 $this->request = $req;
116 if ( $reload || is_null($this->matchedRoutes) ) {
117 $this->matchedRoutes =
array();
118 foreach ( $this->routes as $route ) {
119 if ( $route->matches($this->request->getResourceUri()) ) {
120 $this->matchedRoutes[] = $route;
133 public function map( $pattern, $callable ) {
135 $route->setRouter($this);
136 $this->routes[] = $route;
148 if ( isset($this->namedRoutes[(
string)$name]) ) {
149 throw new RuntimeException(
'Named route already exists with name: ' . $name);
151 $this->namedRoutes[$name] = $route;
162 if ( !isset($this->namedRoutes[(
string)$name]) ) {
165 $pattern = $this->namedRoutes[(
string)$name]->getPattern();
166 $search = $replace =
array();
167 foreach (
$params as $key => $value ) {
168 $search[] =
':' . $key;
171 $pattern = str_replace($search, $replace, $pattern);
173 return preg_replace(
array(
174 '@\(\/?:.+\/??\)\??@',
176 ),
'', $this->request->getRootUri() . $pattern);
185 if ( is_callable($callable) ) {
196 public function error( $callable = null ) {
197 if ( is_callable($callable) ) {
198 $this->
error = $callable;
urlFor( $name, $params=array())
Get URL for named route.
Add rich text string
The name of the decorator.
error( $callable=null)
Register a 500 Error callback.
__construct(Slim_Http_Request $request)
Constructor.
notFound( $callable=null)
Register a 404 Not Found callback.
Create styles array
The data for the language used.
getMatchedRoutes( $reload=false)
Return routes that match the current request.
setRequest(Slim_Http_Request $req)
Set Request.
map( $pattern, $callable)
Map a route to a callback function.
getIterator()
Get Iterator.
cacheNamedRoute( $name, Slim_Route $route)
Cache named route.