public function TBMegaMenuAdminController::loadMenuConfig in The Better Mega Menu 8
Same name and namespace in other branches
- 2.x src/Controller/TBMegaMenuAdminController.php \Drupal\tb_megamenu\Controller\TBMegaMenuAdminController::loadMenuConfig()
Loads a menu configuration.
Parameters
array $data: A decoded JSON object used to load the configuration.
Return value
array The message and status code indicating the result of the load attempt.
1 call to TBMegaMenuAdminController::loadMenuConfig()
- TBMegaMenuAdminController::saveConfiguration in src/
Controller/ TBMegaMenuAdminController.php - Ajax callback for admin screen.
File
- src/
Controller/ TBMegaMenuAdminController.php, line 125
Class
- TBMegaMenuAdminController
- Handler for configuring and saving MegaMenu settings.
Namespace
Drupal\tb_megamenu\ControllerCode
public function loadMenuConfig(array $data) {
$menu_name = self::getMenuName($data);
$theme = self::getTheme($data);
$code = 200;
// Attempt to load the menu config.
if ($menu_name && $theme) {
$renderable_array = $this->menuBuilder
->renderBlock($menu_name, $theme);
$result = $this->renderer
->render($renderable_array)
->__toString();
}
else {
$result = self::saveError('load_config');
$code = 500;
}
return [
'message' => $result,
'code' => $code,
];
}