You are here

public function DomainStorage::createMachineName in Domain Access 8

Creates a machine-name string from the hostname.

This string is the primary key of the entity.

Parameters

string $hostname: The hostname of the domain record. If empty, the current request will be used.

Return value

string A string containing A-Z, a-z, 0-9, and _ characters.

Overrides DomainStorageInterface::createMachineName

File

domain/src/DomainStorage.php, line 183

Class

DomainStorage
Loads Domain records.

Namespace

Drupal\domain

Code

public function createMachineName($hostname = NULL) {
  if (empty($hostname)) {
    $hostname = $this
      ->createHostname();
  }
  return preg_replace('/[^a-z0-9_]/', '_', $hostname);
}