Esempio n. 1
0
 /**
  * parseHostVars
  *
  * @param RouteInterface $route
  *
  * @return array
  */
 private static function parseHostVars(RouteInterface $route)
 {
     if (null === ($host = $route->getHost())) {
         return ['expression' => null, 'tokens' => []];
     }
     return self::transpilePattern($host, true, $route->getConstraints(), $route->getDefaults());
 }
Esempio n. 2
0
 /**
  * getPathPrefix
  *
  * @param RouteInterface $route
  * @param array $parameters
  * @param mixed $host
  *
  * @return mixed
  */
 private function getPathPrefix(RouteInterface $route, $host = null)
 {
     $context = $route->getContext();
     if (null === $host) {
         $host = $route->getHost() ? $route->getHost() : $this->request->getHost();
     }
     if (null !== $route->getHost() && !(bool) preg_match($context->getHostRegex(), $host)) {
         throw new \InvalidArgumentException('Host requirement does not match given host.');
     }
     return sprintf('%s://%s', $this->getRouteProtocol($route, $this->getRequest()), $host);
 }