class IHaveRuntimeContexts

Same name in this branch
  1. 9 core/modules/layout_builder/tests/modules/layout_builder_test/src/ContextProvider/IHaveRuntimeContexts.php \Drupal\layout_builder_test\ContextProvider\IHaveRuntimeContexts
Same name and namespace in other branches
  1. 11.x core/modules/layout_builder/tests/modules/layout_builder_test/src/ContextProvider/IHaveRuntimeContexts.php \Drupal\layout_builder_test\ContextProvider\IHaveRuntimeContexts
  2. 11.x core/modules/layout_builder/tests/modules/layout_builder_test/src/Plugin/Block/IHaveRuntimeContexts.php \Drupal\layout_builder_test\Plugin\Block\IHaveRuntimeContexts

Defines a class for a context-aware block.

Plugin annotation


@Block(
  id = "i_have_runtime_contexts",
  admin_label = "Can I have runtime contexts",
  category = "Test",
  context_definitions = {
    "runtime_contexts" = @ContextDefinition("string", label = "Do you have runtime contexts")
  }
)

Hierarchy

Expanded class hierarchy of IHaveRuntimeContexts

File

core/modules/layout_builder/tests/modules/layout_builder_test/src/Plugin/Block/IHaveRuntimeContexts.php, line 19

Namespace

Drupal\layout_builder_test\Plugin\Block
View source
class IHaveRuntimeContexts extends BlockBase {
  
  /**
   * {@inheritdoc}
   */
  public function build() {
    return [
      '#markup' => $this->getContextValue('runtime_contexts'),
    ];
  }

}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.