You are here

private function AccordionMenusBlock::generateSubMenuTree in Accordion Menus 8

Same name and namespace in other branches
  1. 8.4 src/Plugin/Block/AccordionMenusBlock.php \Drupal\accordion_menus\Plugin\Block\AccordionMenusBlock::generateSubMenuTree()
  2. 8.2 src/Plugin/Block/AccordionMenusBlock.php \Drupal\accordion_menus\Plugin\Block\AccordionMenusBlock::generateSubMenuTree()
  3. 8.3 src/Plugin/Block/AccordionMenusBlock.php \Drupal\accordion_menus\Plugin\Block\AccordionMenusBlock::generateSubMenuTree()
1 call to AccordionMenusBlock::generateSubMenuTree()
AccordionMenusBlock::build in src/Plugin/Block/AccordionMenusBlock.php
Builds and returns the renderable array for this block plugin.

File

src/Plugin/Block/AccordionMenusBlock.php, line 55

Class

AccordionMenusBlock
Provides a accordion Menu block.

Namespace

Drupal\accordion_menus\Plugin\Block

Code

private function generateSubMenuTree($menu) {
  $output = [];
  $item_lists = [];
  foreach ($menu as $item) {

    //If menu element disabled skip this branch
    if ($item->link
      ->isEnabled()) {
      $item_lists[] = Link::fromTextAndUrl($item->link
        ->getTitle(), $item->link
        ->getUrlObject());
    }
  }
  $output = [
    '#theme' => 'item_list',
    '#items' => $item_lists,
  ];
  return $output;
}