Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  *
  * @throws RuntimeException
  */
 public function assemble($routeName, array $params = [], array $options = [])
 {
     $nameParts = explode('/', $routeName, 2);
     $parentName = $nameParts[0];
     $childName = isset($nameParts[1]) ? $nameParts[1] : null;
     $assemblyResult = $this->routeCollection->get($parentName)->assemble($params, $childName);
     $assemblyResult->path = $this->baseUri['path'] . $assemblyResult->path;
     if (isset($options['query'])) {
         $assemblyResult->query = $options['query'];
     }
     if (isset($options['fragment'])) {
         $assemblyResult->fragment = $options['fragment'];
     }
     return $assemblyResult->generateUri($this->baseUri['scheme'], $this->baseUri['host'], $this->baseUri['port'], isset($options['enforce_absolute_uri']) && $options['enforce_absolute_uri']);
 }
Ejemplo n.º 2
0
 /**
  * {@inheritdoc}
  *
  * @throws Exception\RuntimeException
  */
 public function assemble(array $params, $childName = null)
 {
     if ($childName !== null) {
         $nameParts = explode('/', $childName, 2);
         $parentName = $nameParts[0];
         $childName = isset($nameParts[1]) ? $nameParts[1] : null;
         if ($this->children === null) {
             throw new Exception\RuntimeException('Route has no children to assemble');
         }
         $assemblyResult = $this->children->get($parentName)->assemble($params, $childName);
     } else {
         $assemblyResult = new AssemblyResult();
     }
     if (null !== $this->secure) {
         $assemblyResult->scheme = $this->secure ? 'https' : 'http';
     }
     if (null !== $this->port) {
         $assemblyResult->port = $this->port;
     }
     if ($this->hostnameParser !== null) {
         $assemblyResult->host = $this->hostnameParser->compile($params, $this->defaults);
     }
     if ($this->pathParser !== null) {
         $assemblyResult->path = $this->pathParser->compile($params, $this->defaults) . $assemblyResult->path;
     }
     return $assemblyResult;
 }