Arcanedev\Localization\Contracts\RouteTranslatorInterface::getUrlFromRouteName PHP Method

getUrlFromRouteName() public method

Get URL from route name.
public getUrlFromRouteName ( string $locale, string $defaultLocale, string $transKey, array $attributes = [], boolean | false $defaultHidden = false ) : string
$locale string
$defaultLocale string
$transKey string
$attributes array
$defaultHidden boolean | false
return string
    public function getUrlFromRouteName($locale, $defaultLocale, $transKey, $attributes = [], $defaultHidden = false);

Usage Example

Example #1
0
 /**
  * Returns an URL adapted to the route name and the locale given.
  *
  * @param  string  $locale
  * @param  string  $transKey
  * @param  array   $attributes
  *
  * @return string|false
  */
 public function getUrlFromRouteName($locale, $transKey, $attributes = [])
 {
     $this->isLocaleSupportedOrFail($locale);
     $route = $this->routeTranslator->getUrlFromRouteName($locale, $this->getDefaultLocale(), $transKey, $attributes, $this->isDefaultLocaleHiddenInUrl());
     // This locale does not have any key for this route name
     if (empty($route)) {
         return false;
     }
     return rtrim($this->createUrlFromUri($route));
 }