more refactoring for dependency injection.
This commit is contained in:
@@ -101,6 +101,8 @@ class Router {
|
||||
{
|
||||
foreach (explode(', ', $keys) as $key)
|
||||
{
|
||||
if ( ! is_null($formats = $this->provides($callback))) $key .= '(\.('.implode('|', $formats).'))?';
|
||||
|
||||
if (preg_match('#^'.$this->translate_wildcards($key).'$#', $destination))
|
||||
{
|
||||
return $this->request->route = new Route($keys, $callback, $this->parameters($destination, $key), $this->controller_path);
|
||||
@@ -172,6 +174,17 @@ class Router {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the request formats for which the route provides responses.
|
||||
*
|
||||
* @param mixed $callback
|
||||
* @return array
|
||||
*/
|
||||
protected function provides($callback)
|
||||
{
|
||||
return (is_array($callback) and isset($callback['provides'])) ? explode(', ', $callback['provides']) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate route URI wildcards into actual regular expressions.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user