public function TBMegaMenuBlock::build in The Better Mega Menu 8
Same name and namespace in other branches
- 2.x src/Plugin/Block/TBMegaMenuBlock.php \Drupal\tb_megamenu\Plugin\Block\TBMegaMenuBlock::build()
Builds and returns the renderable array for this block plugin.
If a block should not be rendered because it has no content, then this method must also ensure to return no content: it must then only return an empty array, or an empty array with #cache set (with cacheability metadata indicating the circumstances for it being empty).
Return value
array A renderable array representing the content of the block.
Overrides BlockPluginInterface::build
See also
\Drupal\block\BlockViewBuilder
File
- src/
Plugin/ Block/ TBMegaMenuBlock.php, line 82
Class
- TBMegaMenuBlock
- Provides blocks which belong to TB Mega Menu.
Namespace
Drupal\tb_megamenu\Plugin\BlockCode
public function build() {
$menu_name = $this
->getDerivativeId();
$theme_name = $this
->getThemeName();
$menu = $this->menuBuilder
->getMenus($menu_name, $theme_name);
if ($menu === NULL) {
return [];
}
return [
'#theme' => 'tb_megamenu',
'#menu_name' => $menu_name,
'#block_theme' => $theme_name,
'#attached' => [
'library' => [
'tb_megamenu/theme.tb_megamenu',
],
],
'#post_render' => [
'\\Drupal\\tb_megamenu\\Controller\\TBMegaMenuController::tbMegamenuAttachNumberColumns',
],
];
}