/** * @inheritdoc * @param array $matches The list of regex matches */ public function isMatch(ParsedRoute $route, Request $request, array &$matches = []) { $isMatch = preg_match($route->getHostRegex(), $request->getHeaders()->get("HOST"), $matches) === 1; // Remove the subject array_shift($matches); return $isMatch; }
/** * Generates the host portion of a URL for a route * * @param ParsedRoute $route The route whose URL we're generating * @param mixed|array $values The value or list of values to fill the route with * @return string The generated host value * @throws URLException Thrown if the generated host is not valid */ private function generateHost(ParsedRoute $route, &$values) { $host = ""; if (!empty($route->getRawHost())) { $host = $this->generateUrlPart($route->getRawHost(), $route->getHostRegex(), $route->getName(), $values); // Prefix the URL with the protocol $host = "http" . ($route->isSecure() ? "s" : "") . "://" . $host; } return $host; }