/**
  * Generate a URI from the named route.
  *
  * Takes the named route and any substitutions, and attempts to generate a
  * URI from it.
  *
  * @see https://github.com/auraphp/Aura.Router#generating-a-route-path
  * @see http://framework.zend.com/manual/current/en/modules/zend.mvc.routing.html
  * @param string $name
  * @param array $substitutions
  * @return string
  * @throws Exception\RuntimeException if unable to generate the given URI.
  */
 public function generateUri($name, array $substitutions = [])
 {
     if (!$this->router->hasNamedRoute($name)) {
         throw new Exception\RuntimeException(sprintf('Cannot generate URI based on route "%s"; route not found', $name));
     }
     return $this->router->urlFor($name, $substitutions);
 }
示例#2
0
 /**
  * Get the URL for a named route
  * @param  string               $name       The route name
  * @param  array                $params     Associative array of URL parameters and replacement values
  * @throws \RuntimeException    If named route does not exist
  * @return string
  */
 public function urlFor($name, $params = array())
 {
     return $this->request->getRootUri() . $this->router->urlFor($name, $params);
 }
 /**
  * @param string $routeName
  * @param array $arguments
  * @return string
  */
 public function urlFor($routeName, array $arguments = [])
 {
     return sprintf('%s%s', $this->request->getRootUri(), $this->router->urlFor($routeName, $arguments));
 }