public function EntityReference::getTargetIdentifier in Drupal 8
Same name and namespace in other branches
- 9 core/lib/Drupal/Core/Entity/Plugin/DataType/EntityReference.php \Drupal\Core\Entity\Plugin\DataType\EntityReference::getTargetIdentifier()
- 10 core/lib/Drupal/Core/Entity/Plugin/DataType/EntityReference.php \Drupal\Core\Entity\Plugin\DataType\EntityReference::getTargetIdentifier()
Gets the identifier of the referenced data.
Return value
int|string|null The identifier of the referenced data, or NULL if the reference is unset.
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\DataTypeCode
public function getTargetIdentifier() {
if (isset($this->id)) {
return $this->id;
}
elseif ($entity = $this
->getValue()) {
return $entity
->id();
}
}