public function WeMegaMenuBlock::build in Drupal Mega Menu 8
Same name and namespace in other branches
- 8.x src/Plugin/Block/WeMegaMenuBlock.php \Drupal\we_megamenu\Plugin\Block\WeMegaMenuBlock::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/ WeMegaMenuBlock.php, line 24
Class
- WeMegaMenuBlock
- Provides a 'Drupal 8 Mega Menu' Block.
Namespace
Drupal\we_megamenu\Plugin\BlockCode
public function build() {
$build = [
'#theme' => 'we_megamenu_frontend',
'#menu_name' => $this
->getDerivativeId(),
'#blocks' => WeMegaMenuBuilder::getAllBlocks(),
'#block_theme' => \Drupal::config('system.theme')
->get('default'),
'#attached' => [
'library' => [
'we_megamenu/form.we-mega-menu-frontend',
],
],
];
return $build;
}