You are here

function template_preprocess_tb_megamenu_backend in The Better Mega Menu 8

Same name and namespace in other branches
  1. 7 tb_megamenu.themes.inc \template_preprocess_tb_megamenu_backend()
  2. 2.x tb_megamenu.module \template_preprocess_tb_megamenu_backend()

Prepare variables for tb_megamenu_backend.

Parameters

array $vars: Variables are declared in theme.

File

./tb_megamenu.module, line 453
TB Mega Menu.

Code

function template_preprocess_tb_megamenu_backend(array &$vars) {
  $menu_name = $vars['menu_name'];
  $theme = $vars['block_theme'];
  $menu_builder = \Drupal::service('tb_megamenu.menu_builder');
  $block_config = $menu_builder
    ->getBlockConfig($menu_name, $theme);
  $menu_builder
    ->editBlockConfig($block_config);
  $vars['menu_content'] = $menu_builder
    ->renderBlock($menu_name, $theme);
  $vars['item_toolbox'] = [
    '#theme' => 'tb_megamenu_item_toolbox',
  ];
  $vars['submenu_toolbox'] = [
    '#theme' => 'tb_megamenu_submenu_toolbox',
  ];
  $vars['column_toolbox'] = [
    '#theme' => 'tb_megamenu_column_toolbox',
    '#blocks_options' => $menu_builder
      ->getAllBlocks($theme),
  ];
  $vars['block_config'] = $block_config;
  $vars['animation_options'] = $menu_builder
    ->createAnimationOptions($block_config);
  $vars['style_options'] = $menu_builder
    ->createStyleOptions($block_config);
  $vars['edit_links'] = Url::fromRoute('entity.menu.edit_form', [
    'menu' => $menu_name,
  ])
    ->toString();

  // Attach this to init TB Mega Menu (Importance).
  $vars['#attached']['drupalSettings']['TBMegaMenu']['menu_name'] = $menu_name;
}