public function TBMegaMenuAdminController::loadMenuBlock in The Better Mega Menu 8
Same name and namespace in other branches
- 2.x src/Controller/TBMegaMenuAdminController.php \Drupal\tb_megamenu\Controller\TBMegaMenuAdminController::loadMenuBlock()
Loads a menu block.
Parameters
array $data: A decoded JSON object used to load the block.
Return value
array The message and status code indicating the result of the load attempt.
1 call to TBMegaMenuAdminController::loadMenuBlock()
- TBMegaMenuAdminController::saveConfiguration in src/
Controller/ TBMegaMenuAdminController.php - Ajax callback for admin screen.
File
- src/
Controller/ TBMegaMenuAdminController.php, line 263
Class
- TBMegaMenuAdminController
- Handler for configuring and saving MegaMenu settings.
Namespace
Drupal\tb_megamenu\ControllerCode
public function loadMenuBlock(array $data) {
$block_id = isset($data['block_id']) ? $data['block_id'] : NULL;
$id = isset($data['id']) ? $data['id'] : NULL;
$showblocktitle = isset($data['showblocktitle']) ? $data['showblocktitle'] : NULL;
$code = 200;
// Attempt to render the specified block.
if ($block_id && $id) {
$render = [
'#theme' => 'tb_megamenu_block',
'#block_id' => $block_id,
'#section' => 'backend',
'#showblocktitle' => $showblocktitle,
];
$content = $this->renderer
->render($render)
->__toString();
$result = Json::encode([
'content' => $content,
'id' => $id,
]);
}
else {
$result = self::saveError('load_block');
$code = 500;
}
return [
'message' => $result,
'code' => $code,
];
}