function BaseFieldDefinition::getTargetEntityTypeId

Returns the ID of the entity type the field is attached to.

This method should not be confused with EntityInterface::getEntityTypeId() (configurable fields are config entities, and thus implement both interfaces):

Return value

string The entity type ID.

Overrides FieldDefinitionInterface::getTargetEntityTypeId

3 calls to BaseFieldDefinition::getTargetEntityTypeId()
BaseFieldDefinition::getConfig in core/lib/Drupal/Core/Field/BaseFieldDefinition.php
BaseFieldDefinition::getUniqueIdentifier in core/lib/Drupal/Core/Field/BaseFieldDefinition.php
BaseFieldDefinition::getUniqueStorageIdentifier in core/lib/Drupal/Core/Field/BaseFieldDefinition.php

File

core/lib/Drupal/Core/Field/BaseFieldDefinition.php, line 623

Class

BaseFieldDefinition
A class for defining entity fields.

Namespace

Drupal\Core\Field

Code

public function getTargetEntityTypeId() {
  return $this->definition['entity_type'] ?? NULL;
}

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