Exemple #1
0
 private function matchHost(RouteContext $ctx, Request $request, $host = null)
 {
     if (null === $host) {
         return true;
     }
     return (bool) preg_match_all($ctx->getHostRegex(), $request->getHost());
 }
Exemple #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);
 }