Commit 74887986 authored by Taylor Otwell's avatar Taylor Otwell

fixing bugs in router.

parent 775b97ee
......@@ -107,6 +107,8 @@ class Bundle {
*/
public static function routes($bundle)
{
if (static::routed($bundle)) return;
$path = static::path($bundle).'routes'.EXT;
// By setting the bundle property on the router the router knows what
......@@ -116,10 +118,10 @@ class Bundle {
if ( ! static::routed($bundle) and file_exists($path))
{
static::$routed[] = $bundle;
require $path;
}
static::$routed[] = $bundle;
}
/**
......
......@@ -367,14 +367,17 @@ class Router {
// To find a named route, we will iterate through every route defined
// for the application. We will cache the routes by name so we can
// load them very quickly the next time.
foreach (static::all() as $key => $value)
foreach (static::routes() as $method => $routes)
{
if (array_get($value, 'name') === $name)
foreach ($routes as $key => $value)
{
if (isset($value['name']) and $value['name'] === $name)
{
return static::$names[$name] = array($key => $value);
}
}
}
}
/**
* Find the route that uses the given action.
......@@ -397,11 +400,14 @@ class Router {
// To find the route, we'll simply spin through the routes looking
// for a route with a "uses" key matching the action, and if we
// find one we cache and return it.
foreach (static::all() as $uri => $route)
foreach (static::routes() as $method => $routes)
{
if (array_get($route, 'uses') == $action)
foreach ($routes as $key => $value)
{
return static::$uses[$action] = array($uri => $route);
if (isset($value['uses']) and $value['uses'] === $action)
{
return static::$uses[$action] = array($key => $value);
}
}
}
}
......@@ -490,26 +496,6 @@ class Router {
return strtr($key, static::$patterns);
}
/**
* Get all of the routes across all request methods.
*
* @return array
*/
public static function all()
{
$all = array();
// To get all the routes, we'll just loop through each request
// method supported by the router and merge in each of the
// arrays into the main array of routes.
foreach (static::$methods as $method)
{
$all = array_merge($all, static::routes($method));
}
return $all;
}
/**
* Get all of the registered routes, with fallbacks at the end.
*
......
......@@ -244,7 +244,9 @@ class URL {
// should be generated with an HTTPS protocol string or just HTTP.
$https = array_get(current($route), 'https', false);
return static::to(static::transpose(key($route), $parameters), $https);
$uri = trim(static::transpose(key($route), $parameters), '/');
return static::to($uri, $https);
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment