substituteAttributes() public static method

Change uri attributes (wildcards) for the ones in the $attributes array.
public static substituteAttributes ( array $attributes, string $uri ) : string
$attributes array
$uri string
return string
Exemplo n.º 1
0
 /**
  * Get URL from route name.
  *
  * @param  string      $locale
  * @param  string      $defaultLocale
  * @param  string      $transKey
  * @param  array       $attributes
  * @param  bool|false  $defaultHidden
  *
  * @return string
  */
 public function getUrlFromRouteName($locale, $defaultLocale, $transKey, $attributes = [], $defaultHidden = false)
 {
     if (!is_string($locale)) {
         $locale = $defaultLocale;
     }
     $route = '';
     if (!($locale === $defaultLocale && $defaultHidden)) {
         $route = '/' . $locale;
     }
     if ($this->hasTranslation($transKey, $locale)) {
         $translation = $this->trans($transKey, $locale);
         $route = Url::substituteAttributes($attributes, $route . '/' . $translation);
     }
     return $route;
 }