You are here

public function ConditionGroup::evaluate in Block Visibility Groups 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/Plugin/Condition/ConditionGroup.php, line 62

Class

ConditionGroup
Provides a 'Condition Group' condition.

Namespace

Drupal\block_visibility_groups\Plugin\Condition

Code

public function evaluate() {
  $block_visibility_group_id = $this->configuration['block_visibility_group'];
  if (empty($block_visibility_group_id)) {
    return TRUE;
  }

  /** @var \Drupal\block_visibility_groups\Entity\BlockVisibilityGroup $block_visibility_group */
  if ($block_visibility_group = $this->entityStorage
    ->load($block_visibility_group_id)) {
    return $this->groupEvaluator
      ->evaluateGroup($block_visibility_group);
  }
  else {

    // Group doesn't exist.
    // @todo How to handle?
    return FALSE;
  }
}