You are here

public function ViewsSystemDependencies::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/ViewsSystemDependencies.php, line 24
Contains \Drupal\views_system\Plugin\views\field\ViewsSystemDependencies.

Class

ViewsSystemDependencies
Field handler to display all dependencies of a module.

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 $module) {
        $dependency = ModuleHandler::parseDependency($module);
        $label = db_query('SELECT label FROM {views_system} WHERE name = :name', array(
          ':name' => $dependency['name'],
        ))
          ->fetchField();
        $this->items[$field][$module]['label'] = $label;
        $this->items[$field][$module]['name'] = $dependency['name'];
        $this->items[$field][$module]['version'] = isset($dependency['original_version']) ? trim($dependency['original_version']) : '';
      }
    }
  }
}