reimplement locale uri slugs.

This commit is contained in:
Taylor Otwell
2012-08-20 10:46:23 -05:00
parent 7298c93be1
commit 926cdaa7f5
3 changed files with 71 additions and 6 deletions

View File

@@ -26,7 +26,7 @@ class URL {
*/
public static function current()
{
return static::to(URI::current());
return static::to(URI::current(), null, false, false);
}
/**
@@ -89,9 +89,11 @@ class URL {
*
* @param string $url
* @param bool $https
* @param bool $asset
* @param bool $locale
* @return string
*/
public static function to($url = '', $https = null)
public static function to($url = '', $https = null, $asset = false, $locale = true)
{
// If the given URL is already valid or begins with a hash, we'll just return
// the URL unchanged since it is already well formed. Otherwise we will add
@@ -105,7 +107,17 @@ class URL {
// security for any new links generated. So https for all secure links.
if (is_null($https)) $https = Request::secure();
$root = static::base().'/'.Config::get('application.index');
$root = static::base();
if ( ! $asset)
{
$root .= '/'.Config::get('application.index');
}
if ( ! $asset and $locale and count(Config::get('application.languages')) > 0)
{
$root .= '/'.Config::get('application.language');
}
// Since SSL is not often used while developing the application, we allow the
// developer to disable SSL on all framework generated links to make it more
@@ -232,7 +244,7 @@ class URL {
return rtrim($root, '/').'/'.ltrim($url, '/');
}
$url = static::to($url, $https);
$url = static::to($url, $https, true);
// Since assets are not served by Laravel, we do not need to come through
// the front controller. So, we'll remove the application index specified