You are here

public function ConditionBase::evaluate in GoogleTagManager 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

src/ConditionBase.php, line 183

Class

ConditionBase
Provides a basis for fulfilling contexts for condition plugins.

Namespace

Drupal\google_tag

Code

public function evaluate() {

  // @todo Convert a string list of items to an array and reuse this code.
  $toggle = $this->configuration[$this->toggle];
  $values = $this->configuration[$this->list];
  if (empty($values)) {
    $satisfied = $this
      ->isNegated();
  }
  else {
    $satisfied = in_array($this
      ->contextToEvaluate(), $values);
    $satisfied = $this
      ->isNegated() ? !$satisfied : $satisfied;
  }
  return $satisfied;
}