private function matchHost(RouteContext $ctx, Request $request, $host = null) { if (null === $host) { return true; } return (bool) preg_match_all($ctx->getHostRegex(), $request->getHost()); }
/** * getRouteVars * * @param RouteContextInterface $context * @param array $parameters * * @return array */ private function getRouteVars(RouteContextInterface $context, array $parameters) { return array_merge(array_combine(array_values($v = $context->getVars()), array_fill(1, count($v), null)), $parameters); }
/** * Adds a route to the collection that handles the given request * methods. * * @param string $methods methods seperated by a pipe |. * @param string $pattern * @param string $handler * @param array $requirements * @param array $defaults * * @return void */ public function addRoute($methods, $pattern, $handler, array $requirements = [], array $defaults = []) { list($name, $host, $schemes, $constraints) = $this->parseRequirements($this->extendRequirements($requirements), $methods); $route = new Route($this->prefixPattern($pattern), $handler, is_array($methods) ? $methods : explode('|', $methods), $host, $defaults, $constraints, is_array($schemes) ? $schemes : explode('|', $schemes)); $this->routes->add($name, $route); }