Neos.Neos/Classes/Domain/Service/DomainMatchingStrategy.php
public function getSortedMatches($hostnameToMatch, array $domains)
    {
        $matchingDomains = [];
        $matchQualities = [];
        $hostnameToMatchPartsReverse = array_reverse(explode('.', $hostnameToMatch));

        foreach ($domains as $domain) {
            $domainHostname = $domain->getHostname();

            if ($hostnameToMatch === $domainHostname) {
                $matchQuality = self::EXACTMATCH;
            } else {
                $matchQuality = 0;
                $domainHostnamePartsReverse = array_reverse(explode('.', $domainHostname));
                foreach ($domainHostnamePartsReverse as $index => $domainHostnamePart) {
                    if (isset($hostnameToMatchPartsReverse[$index]) && $domainHostnamePart === $hostnameToMatchPartsReverse[$index]) {
                        $matchQuality++;
                    } else {
                        $matchQuality = self::NOMATCH;
                        break;
                    }
                }
            }

            if ($matchQuality > 0) {
                $matchingDomains[] = $domain;
                $matchQualities[] = $matchQuality;
            }
        }

        array_multisort($matchQualities, SORT_DESC, $matchingDomains);
        return $matchingDomains;
    }
public function getSortedMatches($hostnameToMatch, array $domains)
    {
        $matchingDomains = [];
        $matchQualities = [];
        $hostnameToMatchPartsReverse = array_reverse(explode('.', $hostnameToMatch));

        foreach ($domains as $domain) {
            $domainHostname = $domain->getHostname();

            if ($hostnameToMatch === $domainHostname) {
                $matchQuality = self::EXACTMATCH;
            } else {
                $matchQuality = 0;
                $domainHostnamePartsReverse = array_reverse(explode('.', $domainHostname));
                foreach ($domainHostnamePartsReverse as $index => $domainHostnamePart) {
                    if (isset($hostnameToMatchPartsReverse[$index]) && $domainHostnamePart === $hostnameToMatchPartsReverse[$index]) {
                        $matchQuality++;
                    } else {
                        $matchQuality = self::NOMATCH;
                        break;
                    }
                }
            }

            if ($matchQuality > 0) {
                $matchingDomains[] = $domain;
                $matchQualities[] = $matchQuality;
            }
        }

        array_multisort($matchQualities, SORT_DESC, $matchingDomains);
        return $matchingDomains;
    }
public function getSortedMatches ( $ hostnameToMatch , array $ domains ) { $ matchingDomains = [ ] ; $ matchQualities = [ ] ; $ hostnameToMatchPartsReverse = array_reverse ( explode ( '.' , $ hostnameToMatch ) ) ; foreach ( $ domains as $ domain ) { $ domainHostname = $ domain -> getHostname ( ) ; if ( $ hostnameToMatch === $ domainHostname ) { $ matchQuality = self :: EXACTMATCH ; } else { $ matchQuality = 0 ; $ domainHostnamePartsReverse = array_reverse ( explode ( '.' , $ domainHostname ) ) ; foreach ( $ domainHostnamePartsReverse as $ index => $ domainHostnamePart ) { if ( isset ( $ hostnameToMatchPartsReverse [ $ index ] ) && $ domainHostnamePart === $ hostnameToMatchPartsReverse [ $ index ] ) { $ matchQuality ++ ; } else { $ matchQuality = self :: NOMATCH ; break ; } } } if ( $ matchQuality > 0 ) { $ matchingDomains [ ] = $ domain ; $ matchQualities [ ] = $ matchQuality ; } } array_multisort ( $ matchQualities , SORT_DESC , $ matchingDomains ) ; return $ matchingDomains ; }
Returns those of the given domains which match the specified hostname.

The domains are sorted by their match exactness.
If none really matches an empty array is returned.

@param string $hostnameToMatch The hostname to match against (eg. "localhost" or "www.neos.io")
@param array<\Neos\Neos\Domain\Model\Domain> $domains The domains to check
@return array The matching domains
Returns those of the given domains which match the specified hostname .