You are here

public function Vid::titleQuery in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/node/src/Plugin/views/argument/Vid.php \Drupal\node\Plugin\views\argument\Vid::titleQuery()

Override the behavior of title(). Get the title of the revision.

Overrides NumericArgument::titleQuery

File

core/modules/node/src/Plugin/views/argument/Vid.php, line 73
Contains \Drupal\node\Plugin\views\argument\Vid.

Class

Vid
Argument handler to accept a node revision id.

Namespace

Drupal\node\Plugin\views\argument

Code

public function titleQuery() {
  $titles = array();
  $results = $this->database
    ->query('SELECT nr.vid, nr.nid, npr.title FROM {node_revision} nr WHERE nr.vid IN ( :vids[] )', array(
    ':vids[]' => $this->value,
  ))
    ->fetchAllAssoc('vid', PDO::FETCH_ASSOC);
  $nids = array();
  foreach ($results as $result) {
    $nids[] = $result['nid'];
  }
  $nodes = $this->nodeStorage
    ->loadMultiple(array_unique($nids));
  foreach ($results as $result) {
    $nodes[$result['nid']]
      ->set('title', $result['title']);
    $titles[] = $nodes[$result['nid']]
      ->label();
  }
  return $titles;
}