/** * (non-PHPdoc) * @see \Slince\Router\Validator\ValidatorInterface::validate() */ function validate(RouteInterface $route, RequestContext $context) { $matches = []; $result = !$route->getCompiledRoute()->getHostRegex() || preg_match($route->getCompiledRoute()->getHostRegex(), $context->getHost(), $matches); if ($result) { $route->setReport(self::$id, $matches); } return $result; }
/** * 获取route的domain * @param RouteInterface $route * @return string */ protected function _getRouteDomain(RouteInterface $route) { // 如果route没有主机域名限制则直接使用环境中主机 $requireDomain = $route->getDomain(); if (empty($requireDomain)) { return $this->_context->getHost(); } // 有限制则根据route的host限制生成域名 return $this->_formateRouteParameters($requireDomain, $this->_routeParameters, $route->getRequirements()); }