function EntityArgument::titleQuery

Same name and namespace in other branches
  1. 11.x core/modules/views/src/Plugin/views/argument/EntityArgument.php \Drupal\views\Plugin\views\argument\EntityArgument::titleQuery()

Override for specific title lookups.

Return value

array Returns all titles, if it's just one title it's an array with one entry.

Overrides NumericArgument::titleQuery

File

core/modules/views/src/Plugin/views/argument/EntityArgument.php, line 72

Class

EntityArgument
Argument handler to accept an entity ID value.

Namespace

Drupal\views\Plugin\views\argument

Code

public function titleQuery() {
  $titles = [];
  $entities = $this->entityTypeManager
    ->getStorage($this->definition['entity_type'])
    ->loadMultiple($this->value);
  foreach ($entities as $entity) {
    $titles[$entity->id()] = $this->entityRepository
      ->getTranslationFromContext($entity)
      ->label();
  }
  return $titles;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.