112 return self::$defaultConditions;
129 $this->pattern = str_replace(
')',
')?', (
string)
$pattern);
181 $this->router->cacheNamedRoute($this->
name, $this);
197 $args = func_get_args();
198 $this->methods = $args;
214 $args = func_get_args();
215 $this->methods = array_merge($this->methods, $args);
223 $args = func_get_args();
224 $this->methods = array_merge($this->methods, $args);
233 return in_array($method, $this->methods);
280 $this->middleware = array_merge($this->middleware,
$middleware);
300 preg_match_all(
'@:([\w]+)@', $this->pattern, $paramNames, PREG_PATTERN_ORDER);
301 $paramNames = $paramNames[0];
304 $patternAsRegex = preg_replace_callback(
'@:[\w]+@',
array($this,
'convertPatternToRegex'), $this->pattern);
305 if ( substr($this->pattern, -1) ===
'/' ) {
306 $patternAsRegex = $patternAsRegex .
'?';
308 $patternAsRegex =
'@^' . $patternAsRegex .
'$@';
311 if ( preg_match($patternAsRegex, $resourceUri, $paramValues) ) {
312 array_shift($paramValues);
313 foreach ( $paramNames as $index => $value ) {
314 $val = substr($value, 1);
315 if ( isset($paramValues[$val]) ) {
316 $this->params[$val] = urldecode($paramValues[$val]);
331 $key = str_replace(
':',
'', $matches[0]);
332 if ( array_key_exists($key, $this->
conditions) ) {
333 return '(?P<' . $key .
'>' . $this->
conditions[$key] .
')';
335 return '(?P<' . $key .
'>[a-zA-Z0-9_\-\.\!\~\*\\\'\(\)\:\@\&\=\$\+,%]+)';
381 if ( substr($this->pattern, -1) ===
'/' && substr($this->router->getRequest()->getResourceUri(), -1) !==
'/' ) {
385 foreach ( $this->middleware as $mw ) {
386 if ( is_callable($mw) ) {
392 call_user_func_array($this->callable, array_values($this->params));
setCallable($callable)
Set route callable.
getMiddleware()
Get middleware.
getPattern()
Get route pattern.
conditions(array $conditions)
Merge route conditions.
getConditions()
Get route conditions.
setMiddleware( $middleware)
Set middleware.
setPattern( $pattern)
Set route pattern.
getCallable()
Get route callable.
Add rich text string
The name of the decorator.
getParams()
Get route parameters.
__construct( $pattern, $callable)
Constructor.
via()
Append supported HTTP methods (alias for Route::appendHttpMethods)
static getDefaultConditions()
Get default route conditions for all instances.
setHttpMethods()
Add supported HTTP method(s)
supportsHttpMethod( $method)
Detect support for an HTTP method.
static $defaultConditions
matches( $resourceUri)
Matches URI?
convertPatternToRegex( $matches)
Convert a URL parameter (ie.
appendHttpMethods()
Append supported HTTP methods.
Create styles array
The data for the language used.
setName( $name)
Set route name.
getHttpMethods()
Get supported HTTP methods.
name( $name)
Set route name.
setConditions(array $conditions)
Set route conditions.
setRouter(Slim_Router $router)
Set router.
dispatch()
Dispatch route.
static setDefaultConditions(array $defaultConditions)
Set default route conditions for all instances.