You are here

public function DomainStorage::prepareHostname in Domain Access 8

Removes www. prefix from a hostname, if set.

Parameters

string $hostname: A hostname.

Return value

string The cleaned hostname.

Overrides DomainStorageInterface::prepareHostname

1 call to DomainStorage::prepareHostname()
DomainStorage::loadByHostname in domain/src/DomainStorage.php
Loads a domain record by hostname lookup.

File

domain/src/DomainStorage.php, line 142

Class

DomainStorage
Loads Domain records.

Namespace

Drupal\domain

Code

public function prepareHostname($hostname) {

  // Strip www. prefix off the hostname.
  $ignore_www = $this->configFactory
    ->get('domain.settings')
    ->get('www_prefix');
  if ($ignore_www && substr($hostname, 0, 4) == 'www.') {
    $hostname = substr($hostname, 4);
  }
  return $hostname;
}