You are here

public function ReferenceViewBuilder::buildComponents in Bibliography & Citation 8

Same name and namespace in other branches
  1. 2.0.x modules/bibcite_entity/src/ReferenceViewBuilder.php \Drupal\bibcite_entity\ReferenceViewBuilder::buildComponents()

Builds the component fields and properties of a set of entities.

Parameters

&$build: The renderable array representing the entity content.

\Drupal\Core\Entity\EntityInterface[] $entities: The entities whose content is being built.

\Drupal\Core\Entity\Display\EntityViewDisplayInterface[] $displays: The array of entity view displays holding the display options configured for the entity components, keyed by bundle name.

string $view_mode: The view mode in which the entity is being viewed.

Overrides EntityViewBuilder::buildComponents

File

modules/bibcite_entity/src/ReferenceViewBuilder.php, line 75

Class

ReferenceViewBuilder
Reference entity view builder.

Namespace

Drupal\bibcite_entity

Code

public function buildComponents(array &$build, array $entities, array $displays, $view_mode) {
  parent::buildComponents($build, $entities, $displays, $view_mode);
  foreach ($entities as $id => $entity) {
    $bundle = $entity
      ->bundle();
    $display = $displays[$bundle];
    if ($display
      ->getComponent('citation')) {
      $build[$id]['citation'] = [
        '#theme' => 'bibcite_citation',
        '#data' => $this->serializer
          ->normalize($entity, 'csl'),
        '#entity' => $entity,
      ];
    }
  }
}