You are here

public function Domain::evaluate in Domain Access 8

Evaluates the condition and returns TRUE or FALSE accordingly.

Return value

bool TRUE if the condition has been met, FALSE otherwise.

Overrides ConditionInterface::evaluate

File

domain/src/Plugin/Condition/Domain.php, line 120

Class

Domain
Provides a 'Domain' condition.

Namespace

Drupal\domain\Plugin\Condition

Code

public function evaluate() {
  $domains = $this->configuration['domains'];
  if (empty($domains) && !$this
    ->isNegated()) {
    return TRUE;
  }

  // If the context did not load, derive from the request.
  if (!($domain = $this
    ->getContextValue('domain'))) {
    $domain = $this->domainNegotiator
      ->getActiveDomain();
  }

  // No context found?
  if (empty($domain)) {
    return FALSE;
  }

  // NOTE: The context system handles negation for us.
  return (bool) in_array($domain
    ->id(), $domains);
}