You are here

public function EntityReference::getString in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Entity/Plugin/DataType/EntityReference.php \Drupal\Core\Entity\Plugin\DataType\EntityReference::getString()
  2. 10 core/lib/Drupal/Core/Entity/Plugin/DataType/EntityReference.php \Drupal\Core\Entity\Plugin\DataType\EntityReference::getString()

Returns a string representation of the data.

Return value

string The string representation of the data.

Overrides DataReferenceBase::getString

File

core/lib/Drupal/Core/Entity/Plugin/DataType/EntityReference.php, line 120

Class

EntityReference
Defines an 'entity_reference' data type.

Namespace

Drupal\Core\Entity\Plugin\DataType

Code

public function getString() {
  if ($entity = $this
    ->getValue()) {
    return $entity
      ->label();
  }
  return '';
}