You are here

public function MenuMultilingualLinkTreeModifier::filtersLinks in Menu Multilingual 8

Filter wrapper for either links or menu link tree.

Parameters

array $tree: The already built menu tree.

Return value

array The new menu tree.

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

1 call to MenuMultilingualLinkTreeModifier::filtersLinks()
MenuMultilingualLinkTreeModifier::filterLinksInRenderArray in src/Menu/MenuMultilingualLinkTreeModifier.php
Pass menu links from render array of the block to the filter method.

File

src/Menu/MenuMultilingualLinkTreeModifier.php, line 159

Class

MenuMultilingualLinkTreeModifier
Class MenuMultilingualLinkTreeModifier.

Namespace

Drupal\menu_multilingual\Menu

Code

public function filtersLinks(array $tree) {
  $new_tree = [];
  foreach ($tree as $key => $v) {
    if ($tree[$key]['below']) {
      $tree[$key]['below'] = $this
        ->filtersLinks($tree[$key]['below']);
    }
    $link = $tree[$key]['original_link'];
    if ($this
      ->hasTranslationOrIsDefaultLang($link)) {
      $new_tree[$key] = $tree[$key];
    }
  }
  return $new_tree;
}