class NodeContextTestBlock
Same name and namespace in other branches
- 11.x core/modules/node/tests/modules/node_block_test/src/Plugin/Block/NodeContextTestBlock.php \Drupal\node_block_test\Plugin\Block\NodeContextTestBlock
- 10 core/modules/node/tests/modules/node_block_test/src/Plugin/Block/NodeContextTestBlock.php \Drupal\node_block_test\Plugin\Block\NodeContextTestBlock
Provides a 'Node Context Test' block.
Plugin annotation
@Block(
id = "node_block_test_context",
label = @Translation("Node Context Test"),
context_definitions = {
"node" = @ContextDefinition("entity:node", label = @Translation("Node"))
}
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements \Drupal\Component\Plugin\PluginInspectionInterface, \Drupal\Component\Plugin\DerivativeInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait extends \Drupal\Component\Plugin\PluginBase
- class \Drupal\Core\Block\BlockBase implements \Drupal\Core\Block\BlockPluginInterface, \Drupal\Core\Plugin\PluginWithFormsInterface, \Drupal\Core\Plugin\PreviewAwarePluginInterface, \Drupal\Core\Render\PreviewFallbackInterface, \Drupal\Core\Plugin\ContextAwarePluginInterface uses \Drupal\Core\Block\BlockPluginTrait, \Drupal\Core\Plugin\ContextAwarePluginTrait, \Drupal\Core\Plugin\ContextAwarePluginAssignmentTrait extends \Drupal\Core\Plugin\PluginBase
- class \Drupal\node_block_test\Plugin\Block\NodeContextTestBlock extends \Drupal\Core\Block\BlockBase
- class \Drupal\Core\Block\BlockBase implements \Drupal\Core\Block\BlockPluginInterface, \Drupal\Core\Plugin\PluginWithFormsInterface, \Drupal\Core\Plugin\PreviewAwarePluginInterface, \Drupal\Core\Render\PreviewFallbackInterface, \Drupal\Core\Plugin\ContextAwarePluginInterface uses \Drupal\Core\Block\BlockPluginTrait, \Drupal\Core\Plugin\ContextAwarePluginTrait, \Drupal\Core\Plugin\ContextAwarePluginAssignmentTrait extends \Drupal\Core\Plugin\PluginBase
- class \Drupal\Core\Plugin\PluginBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait extends \Drupal\Component\Plugin\PluginBase
Expanded class hierarchy of NodeContextTestBlock
File
-
core/
modules/ node/ tests/ modules/ node_block_test/ src/ Plugin/ Block/ NodeContextTestBlock.php, line 18
Namespace
Drupal\node_block_test\Plugin\BlockView source
class NodeContextTestBlock extends BlockBase {
/**
* {@inheritdoc}
*/
public function build() {
/** @var \Drupal\node\NodeInterface $node */
$node = $this->getContextValue('node');
return [
'#type' => 'inline_template',
'#template' => 'Displaying node #{{ id }}, revision #{{ revision_id }}: {{ title }}',
'#context' => [
'id' => $node->id(),
'revision_id' => $node->getRevisionId(),
'title' => $node->label(),
],
];
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.