function PreviewAwareBlock::build
Same name in other branches
- 9 core/modules/layout_builder/tests/modules/layout_builder_test/src/Plugin/Block/PreviewAwareBlock.php \Drupal\layout_builder_test\Plugin\Block\PreviewAwareBlock::build()
- 11.x core/modules/layout_builder/tests/modules/layout_builder_test/src/Plugin/Block/PreviewAwareBlock.php \Drupal\layout_builder_test\Plugin\Block\PreviewAwareBlock::build()
Overrides BlockPluginInterface::build
File
-
core/
modules/ layout_builder/ tests/ modules/ layout_builder_test/ src/ Plugin/ Block/ PreviewAwareBlock.php, line 21
Class
- PreviewAwareBlock
- Defines a class for a context-aware block.
Namespace
Drupal\layout_builder_test\Plugin\BlockCode
public function build() {
$markup = $this->t('This block is being rendered normally.');
if ($this->inPreview) {
$markup = $this->t('This block is being rendered in preview mode.');
}
return [
'#markup' => $markup,
];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.