You are here

public function AccordionMenusBlock::generateSubMenuTree in Accordion Menus 8.2

Same name and namespace in other branches
  1. 8.4 src/Plugin/Block/AccordionMenusBlock.php \Drupal\accordion_menus\Plugin\Block\AccordionMenusBlock::generateSubMenuTree()
  2. 8 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()

Generate submenu output.

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 94

Class

AccordionMenusBlock
Provides a accordion Menu block.

Namespace

Drupal\accordion_menus\Plugin\Block

Code

public function generateSubMenuTree($sub_menus) {
  $items = [];
  foreach ($sub_menus as $sub_menu) {

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