fixing bugs in router.
This commit is contained in:
parent
775b97ee76
commit
74887986a7
|
@ -107,6 +107,8 @@ public static function start($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 @@ public static function routes($bundle)
|
|||
|
||||
if ( ! static::routed($bundle) and file_exists($path))
|
||||
{
|
||||
static::$routed[] = $bundle;
|
||||
|
||||
require $path;
|
||||
}
|
||||
|
||||
static::$routed[] = $bundle;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -367,11 +367,14 @@ public static function find($name)
|
|||
// 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)
|
||||
{
|
||||
return static::$names[$name] = array($key => $value);
|
||||
if (isset($value['name']) and $value['name'] === $name)
|
||||
{
|
||||
return static::$names[$name] = array($key => $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -397,11 +400,14 @@ public static function uses($action)
|
|||
// 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 @@ protected static function wildcards($key)
|
|||
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 @@ public static function to_route($name, $parameters = array())
|
|||
// 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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue