function EntityTestViewBuilder::buildComponents

Same name in other branches
  1. 9 core/modules/system/tests/modules/entity_test/src/EntityTestViewBuilder.php \Drupal\entity_test\EntityTestViewBuilder::buildComponents()
  2. 8.9.x core/modules/system/tests/modules/entity_test/src/EntityTestViewBuilder.php \Drupal\entity_test\EntityTestViewBuilder::buildComponents()
  3. 10 core/modules/system/tests/modules/entity_test/src/EntityTestViewBuilder.php \Drupal\entity_test\EntityTestViewBuilder::buildComponents()

Overrides EntityViewBuilder::buildComponents

File

core/modules/system/tests/modules/entity_test/src/EntityTestViewBuilder.php, line 19

Class

EntityTestViewBuilder
Defines an entity view builder for a test entity.

Namespace

Drupal\entity_test

Code

public function buildComponents(array &$build, array $entities, array $displays, $view_mode) {
    parent::buildComponents($build, $entities, $displays, $view_mode);
    foreach ($entities as $id => $entity) {
        $build[$id]['label'] = [
            '#weight' => -100,
            '#plain_text' => $entity->label(),
        ];
        $build[$id]['separator'] = [
            '#weight' => -150,
            '#markup' => ' | ',
        ];
        $build[$id]['view_mode'] = [
            '#weight' => -200,
            '#plain_text' => $view_mode,
        ];
    }
}

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