You are here

protected function DomainCommands::getDomainInstanceFromPolicy in Domain Access 8

Return the Domain object corresponding to a policy string.

Parameters

string $policy: In general one of 'prompt' | 'default' | 'ignore' or a domain entity machine name, but this function does not process 'prompt'.

Return value

\Drupal\Core\Entity\EntityInterface|\Drupal\domain\DomainInterface|null The requested domain or NULL if not found.

Throws

\Drupal\domain\Commands\DomainCommandException

1 call to DomainCommands::getDomainInstanceFromPolicy()
DomainCommands::reassignLinkedEntities in domain/src/Commands/DomainCommands.php
Reassign entities of the supplied type to the $policy domain.

File

domain/src/Commands/DomainCommands.php, line 1340

Class

DomainCommands
Drush commands for the domain module.

Namespace

Drupal\domain\Commands

Code

protected function getDomainInstanceFromPolicy($policy) {
  switch ($policy) {

    // Use the Default Domain machine name.
    case 'default':
      $new_domain = $this
        ->domainStorage()
        ->loadDefaultDomain();
      break;

    // Ask interactively for a Domain machine name.
    case 'prompt':
    case 'ignore':
      return NULL;

    // Use this (specified) Domain machine name.
    default:
      $new_domain = $this
        ->domainStorage()
        ->load($policy);
      break;
  }
  return $new_domain;
}