generate() public method

Generate a url from a route.
public generate ( string $name, array $parameters = [], boolean $absolute = true ) : string
$name string Name of the Route.
$parameters array List of parameters that need to be replaced within the Route path.
$absolute boolean Do you want to get the absolute url or relative. Default is absolute.
return string Generated url.
Example #1
0
 /**
  * Generate a url from a route.
  *
  * @param string $name       Name of the Route.
  * @param array  $parameters List of parameters that need to be replaced within the Route path.
  * @param bool   $absolute   Do you want to get the absolute url or relative. Default is absolute.
  *
  * @return string Generated url.
  * @throws RouterException
  */
 public function generate($name, $parameters = [], $absolute = true)
 {
     $key = 'generate.' . $name . implode('|', $parameters) . $absolute;
     if ($url = $this->loadFromCache($key)) {
         return $url;
     }
     $url = $this->urlGenerator->generate($name, $parameters, $absolute);
     $this->saveToCache($key, $url);
     return $url;
 }