You are here

public function EntityLabel::preRender in Commerce License 8.2

Runs before any fields are rendered.

This gives the handlers some time to set up before any handler has been rendered.

Parameters

\Drupal\views\ResultRow[] $values: An array of all ResultRow objects returned from the query.

Overrides EntityLabel::preRender

File

src/Plugin/views/field/EntityLabel.php, line 36

Class

EntityLabel
Field handler to display entity label optionally linked to entity page.

Namespace

Drupal\commerce_license\Plugin\views\field

Code

public function preRender(&$values) {
  $entity_ids_per_type = [];
  foreach ($values as $value) {
    $type = $this
      ->getEntityTypeFromValues($value);
    $entity_ids_per_type[$type][] = $this
      ->getValue($value);
  }
  foreach ($entity_ids_per_type as $type => $ids) {

    // Need to use ->entityTypeManager for Drupal >= 8.8.
    if (property_exists($this, 'entityTypeManager')) {
      $this->loadedReferencers[$type] = $this->entityTypeManager
        ->getStorage($type)
        ->loadMultiple($ids);
    }
    else {
      $this->loadedReferencers[$type] = $this->entityManager
        ->getStorage($type)
        ->loadMultiple($ids);
    }
  }
}