function EntityReference::getTargetIdentifier

Same name in other branches
  1. 9 core/lib/Drupal/Core/Entity/Plugin/DataType/EntityReference.php \Drupal\Core\Entity\Plugin\DataType\EntityReference::getTargetIdentifier()
  2. 10 core/lib/Drupal/Core/Entity/Plugin/DataType/EntityReference.php \Drupal\Core\Entity\Plugin\DataType\EntityReference::getTargetIdentifier()
  3. 11.x core/lib/Drupal/Core/Entity/Plugin/DataType/EntityReference.php \Drupal\Core\Entity\Plugin\DataType\EntityReference::getTargetIdentifier()

Overrides DataReferenceInterface::getTargetIdentifier

File

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

Class

EntityReference
Defines an 'entity_reference' data type.

Namespace

Drupal\Core\Entity\Plugin\DataType

Code

public function getTargetIdentifier() {
    if (isset($this->id)) {
        return $this->id;
    }
    elseif ($entity = $this->getValue()) {
        return $entity->id();
    }
}

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