You are here

public function DomainNegotiator::negotiateActiveHostname in Domain Access 8

Sets the hostname of the active request.

This method is an internal method for use by the public getActiveDomain() call. It is responsible for determining the active hostname of the request and then passing that data to the negotiator.

Return value

string The hostname, without the "www" if applicable.

Overrides DomainNegotiatorInterface::negotiateActiveHostname

1 call to DomainNegotiator::negotiateActiveHostname()
DomainNegotiator::negotiateActiveDomain in domain/src/DomainNegotiator.php
Determine the active domain.

File

domain/src/DomainNegotiator.php, line 172

Class

DomainNegotiator

Namespace

Drupal\domain

Code

public function negotiateActiveHostname() {
  if ($request = $this->requestStack
    ->getCurrentRequest()) {
    $httpHost = $request
      ->getHttpHost();
  }
  else {
    $httpHost = $_SERVER['HTTP_HOST'] ?? NULL;
  }
  $hostname = !empty($httpHost) ? $httpHost : 'localhost';
  return $this
    ->domainStorage()
    ->prepareHostname($hostname);
}