You are here

public function EntityReferenceRevisions::getTargetIdentifier in Entity Reference Revisions 8

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 EntityReference::getTargetIdentifier

File

src/Plugin/DataType/EntityReferenceRevisions.php, line 91

Class

EntityReferenceRevisions
Defines an 'entity_reference_revisions' data type.

Namespace

Drupal\entity_reference_revisions\Plugin\DataType

Code

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