You are here

public function Domain::getScheme in Domain Access 8

Returns the active scheme for a domain record.

This method is to be used when generating URLs.

Parameters

bool $add_suffix: Tells the method to return :// after the string.

Return value

string Returns a valid scheme (http or https), with or without the suffix.

Overrides DomainInterface::getScheme

4 calls to Domain::getScheme()
Domain::getRawPath in domain/src/Entity/Domain.php
Returns the raw path of the domain object, without the base url.
Domain::isHttps in domain/src/Entity/Domain.php
Detects if the domain uses https for links.
Domain::setPath in domain/src/Entity/Domain.php
Sets the base path to this domain.
Domain::setUrl in domain/src/Entity/Domain.php
Sets the domain-specific link to the current URL.

File

domain/src/Entity/Domain.php, line 428

Class

Domain
Defines the domain entity.

Namespace

Drupal\domain\Entity

Code

public function getScheme($add_suffix = TRUE) {
  $scheme = $this->scheme;
  if ($scheme == 'variable') {
    $scheme = \Drupal::entityTypeManager()
      ->getStorage('domain')
      ->getDefaultScheme();
  }
  elseif ($scheme != 'https') {
    $scheme = 'http';
  }
  $scheme .= $add_suffix ? '://' : '';
  return $scheme;
}