You are here

public function ViewsSystemRequires::preRender in Views System 8

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/ViewsSystemRequires.php, line 23
Contains \Drupal\views_system\Plugin\views\field\ViewsSystemRequires.

Class

ViewsSystemRequires
Field handler to display all other items that this item requires.

Namespace

Drupal\views_system\Plugin\views\field

Code

public function preRender(&$values) {
  $this->items = array();
  foreach ($values as $result) {
    $field = $this
      ->getValue($result);
    if (!empty($field) && !isset($this->items[$field])) {
      foreach (unserialize($field) as $item) {
        $name = $item['name'];
        $label = db_query('SELECT label FROM {views_system} WHERE name = :name', array(
          ':name' => $name,
        ))
          ->fetchField();
        $this->items[$field][$name]['label'] = $label;
        $this->items[$field][$name]['name'] = $name;
      }
    }
  }
}