more refactoring for dependency injection.

This commit is contained in:
Taylor Otwell
2011-09-02 19:36:19 -05:00
parent 893bb83895
commit 6281c8c360
8 changed files with 122 additions and 76 deletions

View File

@@ -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.
*