function Vid::title_query

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

Overrides Numeric::title_query

File

drupal/core/modules/node/lib/Drupal/node/Plugin/views/argument/Vid.php, line 28
Definition of Drupal\node\Plugin\views\argument\Vid.

Class

Vid
Argument handler to accept a node revision id.

Namespace

Drupal\node\Plugin\views\argument

Code

function title_query() {
  $titles = array();
  $results = db_select('node_revision', 'nr')
    ->fields('nr', array(
    'vid',
    'nid',
    'title',
  ))
    ->condition('nr.vid', $this->value)
    ->execute()
    ->fetchAllAssoc('vid', PDO::FETCH_ASSOC);
  $nids = array();
  foreach ($results as $result) {
    $nids[] = $result['nid'];
  }
  $nodes = node_load_multiple(array_unique($nids));
  foreach ($results as $result) {
    $nodes[$result['nid']]
      ->set('title', $result['title']);
    $titles[] = check_plain($nodes[$result['nid']]
      ->label());
  }
  return $titles;
}