cleaning up the uri method.
This commit is contained in:
parent
f3be544b1a
commit
ce5a922b87
|
@ -33,22 +33,14 @@ public static function current()
|
||||||
$uri = static::remove($uri, parse_url(URL::base(), PHP_URL_PATH));
|
$uri = static::remove($uri, parse_url(URL::base(), PHP_URL_PATH));
|
||||||
|
|
||||||
// We'll also remove the application's index page as it is not used for at
|
// We'll also remove the application's index page as it is not used for at
|
||||||
// all for routing and is totally unnecessary as far as the framework is
|
// all for routing and is totally unnecessary as far as the routing of
|
||||||
// concerned. It is only in the URI when mod_rewrite is not available.
|
// incoming requests to the framework is concerned.
|
||||||
if (($index = '/'.Config::get('application.index')) !== '/')
|
if (($index = '/'.Config::get('application.index')) !== '/')
|
||||||
{
|
{
|
||||||
$uri = static::remove($uri, $index);
|
$uri = static::remove($uri, $index);
|
||||||
}
|
}
|
||||||
|
|
||||||
static::$uri = static::format($uri);
|
static::segments(static::$uri = static::format($uri));
|
||||||
|
|
||||||
// Cache the URI segments. This allows us to avoid having to explode
|
|
||||||
// the segments every time the developer requests one of them. The
|
|
||||||
// extra slashes have already been stripped off of the URI so no
|
|
||||||
// extraneous elements should be present in the segment array.
|
|
||||||
$segments = explode('/', trim(static::$uri, '/'));
|
|
||||||
|
|
||||||
static::$segments = array_diff($segments, array(''));
|
|
||||||
|
|
||||||
return static::$uri;
|
return static::$uri;
|
||||||
}
|
}
|
||||||
|
@ -75,6 +67,19 @@ public static function segment($index, $default = null)
|
||||||
return array_get(static::$segments, $index - 1, $default);
|
return array_get(static::$segments, $index - 1, $default);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the URI segments for the request.
|
||||||
|
*
|
||||||
|
* @param string $uri
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function segments($uri)
|
||||||
|
{
|
||||||
|
$segments = explode('/', trim($uri, '/'));
|
||||||
|
|
||||||
|
static::$segments = array_diff($segments, array(''));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a given value from the URI.
|
* Remove a given value from the URI.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue