function EntityViewBuilder::build

Same name in other branches
  1. 9 core/lib/Drupal/Core/Entity/EntityViewBuilder.php \Drupal\Core\Entity\EntityViewBuilder::build()
  2. 8.9.x core/lib/Drupal/Core/Entity/EntityViewBuilder.php \Drupal\Core\Entity\EntityViewBuilder::build()
  3. 11.x core/lib/Drupal/Core/Entity/EntityViewBuilder.php \Drupal\Core\Entity\EntityViewBuilder::build()

Builds an entity's view; augments entity defaults.

This function is assigned as a #pre_render callback in ::view().

It transforms the renderable array for a single entity to the same structure as if we were rendering multiple entities, and then calls the default ::buildMultiple() #pre_render callback.

Parameters

array $build: A renderable array containing build information and context for an entity view.

Return value

array The updated renderable array.

See also

\Drupal\Core\Render\RendererInterface::render()

File

core/lib/Drupal/Core/Entity/EntityViewBuilder.php, line 237

Class

EntityViewBuilder
Base class for entity view builders.

Namespace

Drupal\Core\Entity

Code

public function build(array $build) {
    $build_list = [
        $build,
    ];
    $build_list = $this->buildMultiple($build_list);
    return $build_list[0];
}

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