You are here

public function AgreementEntity::preRender in Agreement 3.0.x

Same name and namespace in other branches
  1. 8.2 src/Plugin/views/field/AgreementEntity.php \Drupal\agreement\Plugin\views\field\AgreementEntity::preRender()

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 FieldPluginBase::preRender

File

src/Plugin/views/field/AgreementEntity.php, line 108

Class

AgreementEntity
Provides a field handler for agreement configuration entities.

Namespace

Drupal\agreement\Plugin\views\field

Code

public function preRender(&$values) {
  parent::preRender($values);

  // Get all the configuration entities.
  $agreements = $this->entityTypeManager
    ->getStorage('agreement')
    ->loadMultiple();
  foreach ($values as $index => $result) {
    $value = $this
      ->getValue($result);
    if (isset($agreements[$value])) {
      $values[$index]->_agreement = $agreements[$value];
    }
    else {
      $values[$index]->_agreement = NULL;
    }
  }
}