TestContextAwareLayout.php

Same filename in other branches
  1. 9 core/modules/layout_builder/tests/modules/layout_builder_test/src/Plugin/Layout/TestContextAwareLayout.php
  2. 10 core/modules/layout_builder/tests/modules/layout_builder_test/src/Plugin/Layout/TestContextAwareLayout.php

Namespace

Drupal\layout_builder_test\Plugin\Layout

File

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

View source
<?php

declare (strict_types=1);
namespace Drupal\layout_builder_test\Plugin\Layout;

use Drupal\Core\Layout\Attribute\Layout;
use Drupal\Core\Layout\LayoutDefault;
use Drupal\Core\Plugin\Context\EntityContextDefinition;
use Drupal\Core\StringTranslation\TranslatableMarkup;

/**
 * The TestContextAwareLayout Class.
 */
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;
    }

}

Classes

Title Deprecated Summary
TestContextAwareLayout The TestContextAwareLayout Class.

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