You are here

public function TBMegaMenuBuilder::insertEnabledLinks in The Better Mega Menu 8

Same name and namespace in other branches
  1. 2.x src/TBMegaMenuBuilder.php \Drupal\tb_megamenu\TBMegaMenuBuilder::insertEnabledLinks()

Insert an enabled link into the TB config.

Parameters

array $items: All items in the current menu.

array $hash: An array of hashes for all menu items based on their positions.

array $item_config: The current configuration for all items.

Overrides TBMegaMenuBuilderInterface::insertEnabledLinks

1 call to TBMegaMenuBuilder::insertEnabledLinks()
TBMegaMenuBuilder::syncConfig in src/TBMegaMenuBuilder.php
Populate the item_config values.

File

src/TBMegaMenuBuilder.php, line 429

Class

TBMegaMenuBuilder
Defines a TBMegaMenuBuilder.

Namespace

Drupal\tb_megamenu

Code

public function insertEnabledLinks(array $items, array $hash, array &$item_config) {
  $row = -1;
  $col = -1;
  foreach ($items as $plugin_id => $item) {
    if ($item->link
      ->isEnabled()) {
      if (isset($hash[$plugin_id])) {
        $row = $hash[$plugin_id]['row'];
        $col = $hash[$plugin_id]['col'];
        continue;
      }
      if ($row > -1) {
        self::insertTbMenuItem($item_config, $row, $col, $item);
      }
      else {
        $row = $col = 0;
        while (isset($item_config['rows_content'][$row][$col]['col_content'][0]['type']) && $item_config['rows_content'][$row][$col]['col_content'][0]['type'] == 'block') {
          $row++;
        }
        self::insertTbMenuItem($item_config, $row, $col, $item);
        $item_config['rows_content'][$row][$col]['col_config'] = [];
      }
    }
  }
}