You are here

public function EntityLegalDocumentVersionViewBuilder::buildComponents in Entity Legal 8.2

Same name and namespace in other branches
  1. 4.0.x src/EntityLegalDocumentVersionViewBuilder.php \Drupal\entity_legal\EntityLegalDocumentVersionViewBuilder::buildComponents()
  2. 3.0.x src/EntityLegalDocumentVersionViewBuilder.php \Drupal\entity_legal\EntityLegalDocumentVersionViewBuilder::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

src/EntityLegalDocumentVersionViewBuilder.php, line 17

Class

EntityLegalDocumentVersionViewBuilder
Class EntityLegalDocumentVersionViewBuilder.

Namespace

Drupal\entity_legal

Code

public function buildComponents(array &$build, array $entities, array $displays, $view_mode) {
  parent::buildComponents($build, $entities, $displays, $view_mode);

  /** @var \Drupal\entity_legal\EntityLegalDocumentVersionInterface $entity */
  foreach ($entities as $id => $entity) {

    // Get acceptance form or information for the current user.
    $document = $entity
      ->getDocument();
    $account = \Drupal::currentUser();
    if ($document
      ->userMustAgree() && $account
      ->isAuthenticated()) {
      $build[$id]['acceptance'] = $document
        ->getAcceptanceForm();
      $build[$id]['acceptance']['#weight'] = 99;
    }
  }
}