public function GroupEvaluator::evaluateGroup in Block Visibility Groups 8
Evaluate Block Visibility Group.
Parameters
\Drupal\block_visibility_groups\Entity\BlockVisibilityGroup $block_visibility_group: The block visibility group entity.
Return value
bool TRUE if the group intends to be visible.
Overrides GroupEvaluatorInterface::evaluateGroup
File
- src/
GroupEvaluator.php, line 54
Class
- GroupEvaluator
- Class ConditionEvaluator.
Namespace
Drupal\block_visibility_groupsCode
public function evaluateGroup(BlockVisibilityGroup $block_visibility_group) {
$group_id = $block_visibility_group
->id();
if (!isset($this->group_evaluations[$group_id])) {
/** @var \Drupal\Core\Condition\ConditionPluginCollection $conditions */
$conditions = $block_visibility_group
->getConditions();
if (empty($conditions)) {
// If no conditions then always true.
return TRUE;
}
$logic = $block_visibility_group
->getLogic();
if ($this
->applyContexts($conditions, $logic)) {
$this->group_evaluations[$group_id] = $this
->resolveConditions($conditions, $logic);
}
else {
$this->group_evaluations[$group_id] = FALSE;
}
}
return $this->group_evaluations[$group_id];
}