public function TBMegaMenuBuilder::syncMenuItem in The Better Mega Menu 8
Same name and namespace in other branches
- 2.x src/TBMegaMenuBuilder.php \Drupal\tb_megamenu\TBMegaMenuBuilder::syncMenuItem()
Sync a core menu item with the TB config.
Parameters
array $hash: An array of hashes for all menu items based on their positions.
array $tb_item: The individual menu item.
int|string $row_delta: The delta for the current row.
int|string $col_delta: The delta for the current column.
int|string $item_delta: The delta for the current item.
array $items: All items in the current menu.
array $item_config: The current configuration for all items.
Overrides TBMegaMenuBuilderInterface::syncMenuItem
1 call to TBMegaMenuBuilder::syncMenuItem()
- TBMegaMenuBuilder::syncConfig in src/
TBMegaMenuBuilder.php - Populate the item_config values.
File
- src/
TBMegaMenuBuilder.php, line 375
Class
- TBMegaMenuBuilder
- Defines a TBMegaMenuBuilder.
Namespace
Drupal\tb_megamenuCode
public function syncMenuItem(array &$hash, array $tb_item, $row_delta, $col_delta, $item_delta, array $items, array &$item_config) {
$hash[$tb_item['plugin_id']] = [
'row' => $row_delta,
'col' => $col_delta,
];
$existed = FALSE;
foreach ($items as $plugin_id => $item) {
if ($item->link
->isEnabled() && $tb_item['plugin_id'] == $plugin_id) {
$item_config['rows_content'][$row_delta][$col_delta]['col_content'][$item_delta]['weight'] = $item->link
->getWeight();
$existed = TRUE;
break;
}
}
if (!$existed) {
unset($item_config['rows_content'][$row_delta][$col_delta]['col_content'][$item_delta]);
if (empty($item_config['rows_content'][$row_delta][$col_delta]['col_content'])) {
unset($item_config['rows_content'][$row_delta][$col_delta]);
}
if (empty($item_config['rows_content'][$row_delta])) {
unset($item_config['rows_content'][$row_delta]);
}
}
}