You are here

private function MenuLinkContentVisibilityChecker::evaluateCondition in Custom Menu Links Visibility 8

1 call to MenuLinkContentVisibilityChecker::evaluateCondition()
MenuLinkContentVisibilityChecker::isVisible in src/MenuLinkContentVisibilityChecker.php

File

src/MenuLinkContentVisibilityChecker.php, line 59

Class

MenuLinkContentVisibilityChecker

Namespace

Drupal\menu_link_content_visibility

Code

private function evaluateCondition($condition_id, $condition_configuration) {

  /** @var ConditionInterface $condition */
  $condition = $this->condition_manager
    ->createInstance($condition_id, $condition_configuration);
  if ($condition instanceof ContextAwarePluginInterface) {
    $contexts = $this->context_repository
      ->getRuntimeContexts(array_values($condition
      ->getContextMapping()));
    try {
      $this->context_handler
        ->applyContextMapping($condition, $contexts);
    } catch (ContextException $e) {
      return TRUE;
    }
  }
  return $condition
    ->evaluate();
}