private function DomainAliasStorage::buildPortPatterns in Domain Access 8
Builds a list of matching patterns, including ports.
Parameters
array $patterns: An array of eligible matching patterns.
string $hostname: A hostname string, in the format example.com.
integer $port: The port of the request.
Return value
array An array of eligible matching patterns, modified by port.
1 call to DomainAliasStorage::buildPortPatterns()
- DomainAliasStorage::getPatterns in domain_alias/
src/ DomainAliasStorage.php - Returns an array of eligible matching patterns.
File
- domain_alias/
src/ DomainAliasStorage.php, line 223
Class
- DomainAliasStorage
- Alias loader utility class.
Namespace
Drupal\domain_aliasCode
private function buildPortPatterns(array $patterns, $hostname, $port = NULL) {
// Fetch the port if empty.
if (empty($port) && !empty($this->requestStack
->getCurrentRequest())) {
$port = $this->requestStack
->getCurrentRequest()
->getPort();
}
$new_patterns = [];
foreach ($patterns as $index => $pattern) {
// If default ports, allow exact no-port alias
$new_patterns[] = $pattern . ':*';
if (empty($port) || $port == 80 || $port == 443) {
$new_patterns[] = $pattern;
}
if (!empty($port)) {
$new_patterns[] = $pattern . ':' . $port;
}
}
return $new_patterns;
}