Skip to content

Commit 1815ca0

Browse files
committed
Use only generateFromUrl()
1 parent 05fcb7b commit 1815ca0

File tree

1 file changed

+5
-23
lines changed

1 file changed

+5
-23
lines changed

src/LocalizedUrlGenerator.php

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@ public function __construct()
4646
*/
4747
public function generateFromRequest($locale = null, $parameters = null, $absolute = true)
4848
{
49-
return ($this->isDefault404() || $this->isNonLocalizedFallback404() || ! $this->routeHasName())
50-
? $this->generateFromUrl($locale, $parameters, $absolute)
51-
: $this->generateFromRoute($locale, $parameters, $absolute);
49+
return $this->generateFromUrl($locale, $parameters, $absolute);
5250
}
5351

5452
/**
@@ -114,6 +112,10 @@ protected function generateFromUrl($locale = null, $parameters = null, $absolute
114112
return $currentUrl;
115113
}
116114

115+
if ( ! $this->isNonLocalizedFallback404() && ! $this->isLocalized()) {
116+
return URL::current();
117+
}
118+
117119
$locale = $locale ?: App::getLocale();
118120
$urlParts = parse_url($currentUrl);
119121
$domains = $this->getCustomDomains();
@@ -135,26 +137,6 @@ protected function generateFromUrl($locale = null, $parameters = null, $absolute
135137
return $this->unparseUrl($urlParts);
136138
}
137139

138-
/**
139-
* Generate a localized URL using the current Route instance.
140-
*
141-
* @param string|null $locale
142-
* @param mixed $parameters
143-
* @param bool $absolute
144-
*
145-
* @return string
146-
*/
147-
protected function generateFromRoute($locale = null, $parameters = null, $absolute = true)
148-
{
149-
if ( ! $this->isLocalized()) {
150-
return URL::current();
151-
}
152-
153-
$parameters = $this->prepareParameters($locale, $parameters);
154-
155-
return route($this->route->getName(), $parameters, $absolute, $locale);
156-
}
157-
158140
/**
159141
* Localize the URL path.
160142
*

0 commit comments

Comments
 (0)