You are here

function Vid::title_query in Views (for Drupal 7) 8.3

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

Overrides Numeric::title_query

File

lib/Views/node/Plugin/views/argument/Vid.php, line 28
Definition of Views\node\Plugin\views\argument\Vid.

Class

Vid
Argument handler to accept a node revision id.

Namespace

Views\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;
}