function EntityReferenceArgument::summaryName

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

Provides the name to use for the summary, defaults to the name field.

Parameters

$data: The query results for the row.

Overrides ArgumentPluginBase::summaryName

File

core/modules/views/src/Plugin/views/argument/EntityReferenceArgument.php, line 67

Class

EntityReferenceArgument
Argument handler to accept an entity reference ID value.

Namespace

Drupal\views\Plugin\views\argument

Code

public function summaryName($data) {
  $id = $data->{$this->name_alias};
  $entity = $id ? $this->entityTypeManager
    ->getStorage($this->definition['target_entity_type_id'])
    ->load($id) : NULL;
  if ($entity) {
    return $this->entityRepository
      ->getTranslationFromContext($entity)
      ->label();
  }
  if (($id === NULL || $id === '') && isset($this->definition['empty field name'])) {
    return $this->definition['empty field name'];
  }
  return $id;
}

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