Returns TRUE whether the given site matches the given request.

@param SiteInterface $site    A site instance
@param Request       $request A request instance

@return string|bool FALSE whether the site does not match
197670
protected function matchRequest(SiteInterface $site, Request $request)
    {
        $results = [];

        // we read the value from the attribute to handle fragment support
        $requestPathInfo = $request->get('pathInfo', $request->getPathInfo());

        if (!preg_match(sprintf('@^(%s)(/.*|$)@', $site->getRelativePath()), $requestPathInfo, $results)) {
            return false;
        }

        return $results[2];
    }
77024
public boolean hasParameters(String site) {
		SiteParameters siteParameters = siteParamsMap.get(site);
		if (siteParameters == null) {
			return false;
		}
		return siteParameters.hasParams();
	}
538303
private function requestHeadersMatchExpectation(ServerRequestInterface $httpRequest, Request $expectedRequest)
    {
        foreach ($expectedRequest->getHeaders() as $header => $headerCondition) {
            $inputSource = $this->inputSourceFactory->createFromConfig([
                'header' => $header,
            ]);
            $matcher = $this->matcherFactory->createFromConfig([
                $headerCondition->getMatcher() => $headerCondition->getValue(),
            ]);

            if (!$this->evaluate($inputSource, $matcher, $httpRequest)) {
                return false;
            }
        }

        return true;
    }
235099
public function createForSite(SiteInterface $site)
    {
        $listRedirection = $this->redirectionRepository->findBySiteId($site->getSiteId());
        $siteLanguages = $site->getLanguages();
        $routes = array();

        foreach ($siteLanguages as $language) {
            $nodes = $this->nodeRepository->findPublishedByLanguageAndSiteId($language, $site->getSiteId());
            $routePattern = $this->nodeRepository->findAllRoutePattern($language, $site->getSiteId());
            $routePattern = $this->computeRoutePattern($routePattern);
            foreach ($nodes as $node) {
                $routes = array_merge($this->generateRoutesForNode($node, $site, $routePattern), $routes);
            }
        }

        foreach ($listRedirection as $redirection) {
            $routes = array_merge($this->generateRoutesForRedirection($redirection, $site), $routes);
        }

        return $routes;
    }
1166140
public function matchUrl(RequestInterface $request, array $maps)
    {
        $matched = [];

        $uri = (string)$request->getUri();

        /** @var RequestMap $map */
        foreach ($maps as $map) {
            if ((string)$map->getRequest()->getUri() === $uri) {
                $matched[] = $map;
            }
        }

        return $matched;
    }
81361
protected function _checkUrl(ServerRequestInterface $request)
    {
        return $this->_getUrlChecker()->check(
            $request,
            $this->getConfig('loginUrl'),
            (array)$this->getConfig('urlChecker')
        );
    }
410288
public function hasSite(Site $site)
    {
        return $this->sites()
            ->where(SiteModel::ATTR_ID, '=', $site->getId())
            ->exists();
    }
1207922
private function isMatching(RequestInterface $request, &$route): int
    {
        $match = -1;

        $pattern = str_replace('/', '\/', trim($route['pattern'], '/'));
        $pattern = str_replace(array_keys(self::$expressions), array_values(self::$expressions), $pattern);

        if (preg_match('/^' . $pattern . '$/', ltrim($request->getUri()->getPath(), '/'), $matches)) {
            $match = $this->rate($route['target'], $matches);
        }

        return $match;
    }
763584
public function getSiteNotAvailableRedirectUrl(Site $site)
    {
        if ($site->isSiteAvailable()) {
            return null;
        }

        $defaultDomain = $this->domainService->getDefaultDomainName();

        if (empty($defaultDomain)) {
            return null;
        }

        if ($defaultDomain == $site->getDomain()->getDomainName()) {
            return null;
        }

        return $defaultDomain;
    }
674218
public function match(HttpServletRequestInterface $servletRequest)
    {
        return fnmatch($this->getUrlPattern(), $servletRequest->getServletPath() . $servletRequest->getPathInfo());
    }
149549
public function match(RequestInterface $request, $pathOffset = 0)
    {
        if (!$request instanceof Request) {
            return null;
        }

        $pageUrl = substr($request->getUri()->getPath(), $pathOffset);

        $type = $this->getPageType();

        $pageParams = $this->parseUrl($pageUrl);

        if (empty($pageParams)) {
            return null;
        }

        try {
            $page = $this->getPage($pageParams['pageName'], $type);
        } catch (\Exception $e) {
            return null;
        }

        if (empty($page)) {
            return false;
        }

        $cms_params = array(
            'page' => $page,
            'controller' => $this->getController($type),
            'action' => $this->getAction($type),
            'revision' => $pageParams['revision']
        );

        return new RouteMatch($cms_params, strlen($pageUrl));
    }
437589
public function userCanEditSiteSeo(AccountInterface $account, Site $site) : bool
    {
        return
            $this->isGranted(Permission::VIEW, $site, $account) && (
                $account->hasPermission(SeoService::PERM_SEO_GLOBAL) ||
                $account->hasPermission(SeoService::PERM_SEO_CONTENT_ALL) ||
                $this->siteManager->getAccess()->userIsWebmaster($account, $site)
            )
        ;
    }
94779
private function checkHeader(Request $request, $header)
    {
        if(empty($header))
        {
            return true;
        }
        return Imi::checkCompareRules($header, function($name) use($request){
            return $request->getHeaderLine($name);
        });
    }
1060422
private function match(InternalRequestInterface $request)
    {
        return !$this->hasMatcher()
            || (is_string($this->matcher) && preg_match($this->matcher, (string) $request->getUri()))
            || (is_callable($this->matcher) && call_user_func($this->matcher, $request));
    }
1323747
public function match(RequestInterface $request, array &$attrs = null): bool
    {
        if (empty($this->matchers)) {
            // 不存在匹配器时始终返回 false，便于路由器继续向下探查匹配
            return false;
        }
        foreach ($this->matchers as $matcher) {
            if (!$matcher->match($request, $attrs)) {
                return false;
            }
        }
        return true;
    }
419541
public function matchesPattern(Request $request)
    {
        if (preg_match($this->regexPattern, $request->getRequestUri()) <= 0) {
            return false;
        }

        return true;
    }
1145565
public function match(AddressInterface $address)
    {
        if ($address->getCountryCode() != $this->countryCode) {
            return false;
        }
        if ($this->administrativeArea && $this->administrativeArea != $address->getAdministrativeArea()) {
            return false;
        }
        if ($this->locality && $this->locality != $address->getLocality()) {
            return false;
        }
        if ($this->dependentLocality && $this->dependentLocality != $address->getDependentLocality()) {
            return false;
        }
        if (!PostalCodeHelper::match($address->getPostalCode(), $this->includedPostalCodes, $this->excludedPostalCodes)) {
            return false;
        }

        return true;
    }