You are here

public function Vid::titleQuery in Support Ticketing System 8

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

Overrides NumericArgument::titleQuery

File

modules/support_ticket/src/Plugin/views/argument/Vid.php, line 74
Contains \Drupal\support_ticket\Plugin\views\argument\Vid.

Class

Vid
Argument handler to accept a support ticket revision id.

Namespace

Drupal\support_ticket\Plugin\views\argument

Code

public function titleQuery() {
  $titles = array();
  $results = $this->database
    ->query('SELECT nr.vid, nr.stid, npr.title FROM {support_ticket_revision} nr WHERE nr.vid IN ( :vids[] )', array(
    ':vids[]' => $this->value,
  ))
    ->fetchAllAssoc('vid', PDO::FETCH_ASSOC);
  $stids = array();
  foreach ($results as $result) {
    $stids[] = $result['stid'];
  }
  $support_tickets = $this->supportTicketStorage
    ->loadMultiple(array_unique($stids));
  foreach ($results as $result) {
    $support_tickets[$result['stid']]
      ->set('title', $result['title']);
    $titles[] = SafeMarkup::checkPlain($support_tickets[$result['stid']]
      ->label());
  }
  return $titles;
}