private function DomainAliasStorage::buildPatterns in Domain Access 8
Builds a list of matching patterns.
Parameters
array $parts: The hostname of the request, as an array split by dots.
Return value
array An array of eligible matching patterns.
1 call to DomainAliasStorage::buildPatterns()
- DomainAliasStorage::getPatterns in domain_alias/
src/ DomainAliasStorage.php - Returns an array of eligible matching patterns.
File
- domain_alias/
src/ DomainAliasStorage.php, line 175
Class
- DomainAliasStorage
- Alias loader utility class.
Namespace
Drupal\domain_aliasCode
private function buildPatterns(array $parts) {
$count = count($parts);
for ($i = 0; $i < $count; $i++) {
// Basic replacement of each value.
$temp = $parts;
$temp[$i] = '*';
$patterns[] = implode('.', $temp);
// Advanced multi-value wildcards.
// Pattern *.*.
if (count($temp) > 2 && $i < $count - 1) {
$temp[$i + 1] = '*';
$patterns[] = implode('.', $temp);
}
// Pattern foo.bar.*.
if ($count > 3 && $i < $count - 2) {
$temp[$i + 2] = '*';
$patterns[] = implode('.', $temp);
}
// Pattern *.foo.*.
if ($count > 3 && $i < 2) {
$temp = $parts;
$temp[$i] = '*';
$temp[$i + 2] = '*';
$patterns[] = implode('.', $temp);
}
// Pattern *.foo.*.*.
if ($count > 2) {
$temp = array_fill(0, $count, '*');
$temp[$i] = $parts[$i];
$patterns[] = implode('.', $temp);
}
}
return $patterns;
}