You are here

public function TBMegaMenuAdminController::configMegaMenu in The Better Mega Menu 8

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

This is a menu page. To edit Mega Menu.

1 string reference to 'TBMegaMenuAdminController::configMegaMenu'
tb_megamenu.routing.yml in ./tb_megamenu.routing.yml
tb_megamenu.routing.yml

File

src/Controller/TBMegaMenuAdminController.php, line 349

Class

TBMegaMenuAdminController
Handler for configuring and saving MegaMenu settings.

Namespace

Drupal\tb_megamenu\Controller

Code

public function configMegaMenu(ConfigEntityInterface $tb_megamenu, Request $request) {

  // Add font-awesome library.
  $page['#attached']['library'][] = 'tb_megamenu/form.font-awesome';

  // Add chosen library.
  $page['#attached']['library'][] = 'tb_megamenu/form.chosen';

  // Add a custom library.
  $page['#attached']['library'][] = 'tb_megamenu/form.configure-megamenu';
  Url::fromRoute('tb_megamenu.admin.save', [], [
    'absolute' => TRUE,
  ]);
  $abs_url_config = Url::fromRoute('tb_megamenu.admin.save', [], [
    'absolute' => TRUE,
  ])
    ->toString();
  $page['#attached']['drupalSettings']['TBMegaMenu']['saveConfigURL'] = $abs_url_config;
  if (!empty($tb_megamenu)) {
    $page['tb_megamenu'] = [
      '#theme' => 'tb_megamenu_backend',
      '#menu_name' => $tb_megamenu->menu,
      '#block_theme' => $tb_megamenu->theme,
    ];
  }
  return $page;
}