You are here

private function MenuLinkContentVisibilityCache::buildConditions in Custom Menu Links Visibility 8

1 call to MenuLinkContentVisibilityCache::buildConditions()
MenuLinkContentVisibilityCache::__construct in src/MenuLinkContentVisibilityCache.php

File

src/MenuLinkContentVisibilityCache.php, line 78

Class

MenuLinkContentVisibilityCache

Namespace

Drupal\menu_link_content_visibility

Code

private function buildConditions() {
  $conditions = [];
  if ($visibility = unserialize($this->menu_link_content
    ->get('visibility')->value)) {
    foreach ($visibility as $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) {
        }
      }
      $conditions[$condition_id] = $condition;
    }
  }
  return $conditions;
}