class TestContextAwareLayout

Same name and namespace in other branches
  1. 11.x core/modules/layout_builder/tests/modules/layout_builder_test/src/Plugin/Layout/TestContextAwareLayout.php \Drupal\layout_builder_test\Plugin\Layout\TestContextAwareLayout

Plugin annotation


@Layout(
  id = "layout_builder_test_context_aware",
  label = @Translation("Layout Builder Test: Context Aware"),
  regions = {
    "main" = {
      "label" = @Translation("Main Region")
    }
  },
  context_definitions = {
    "user" = @ContextDefinition("entity:user")
  }
)

Hierarchy

Expanded class hierarchy of TestContextAwareLayout

File

core/modules/layout_builder/tests/modules/layout_builder_test/src/Plugin/Layout/TestContextAwareLayout.php, line 21

Namespace

Drupal\layout_builder_test\Plugin\Layout
View source
class TestContextAwareLayout extends LayoutDefault {
  
  /**
   * {@inheritdoc}
   */
  public function build(array $regions) {
    $build = parent::build($regions);
    $build['main']['#attributes']['class'][] = 'user--' . $this->getContextValue('user')
      ->getAccountName();
    return $build;
  }

}

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