database = $database; $this->nodeStorage = $node_storage; } /** * {@inheritdoc} */ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { return new static( $configuration, $plugin_id, $plugin_definition, $container->get('database'), $container->get('entity.manager')->getStorage('node') ); } /** * Override the behavior of title(). Get the title of the revision. */ public function titleQuery() { $titles = []; $results = $this->database->query('SELECT nr.vid, nr.nid, npr.title FROM {node_revision} nr WHERE nr.vid IN ( :vids[] )', [':vids[]' => $this->value])->fetchAllAssoc('vid', PDO::FETCH_ASSOC); $nids = []; 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; } }