function TestContextAwareBlock::build
Same name in other branches
- 9 core/modules/block/tests/modules/block_test/src/Plugin/Block/TestContextAwareBlock.php \Drupal\block_test\Plugin\Block\TestContextAwareBlock::build()
- 8.9.x core/modules/block/tests/modules/block_test/src/Plugin/Block/TestContextAwareBlock.php \Drupal\block_test\Plugin\Block\TestContextAwareBlock::build()
- 10 core/modules/block/tests/modules/block_test/src/Plugin/Block/TestContextAwareBlock.php \Drupal\block_test\Plugin\Block\TestContextAwareBlock::build()
Overrides BlockPluginInterface::build
File
-
core/
modules/ block/ tests/ modules/ block_test/ src/ Plugin/ Block/ TestContextAwareBlock.php, line 36
Class
- TestContextAwareBlock
- Provides a context-aware block.
Namespace
Drupal\block_test\Plugin\BlockCode
public function build() {
/** @var \Drupal\user\UserInterface $user */
$user = $this->getContextValue('user');
return [
'#prefix' => '<div id="' . $this->getPluginId() . '--username">',
'#suffix' => '</div>',
'#markup' => $user ? $user->getAccountName() : 'No context mapping selected.',
];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.