You are here

public function FieldDefinition::getTargetBundle in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Field/FieldDefinition.php \Drupal\Core\Field\FieldDefinition::getTargetBundle()

Gets the bundle the field is attached to.

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

  • FieldDefinitionInterface::getTargetBundle() answers "as a field, which bundle are you attached to?".
  • EntityInterface::bundle() answers "as a (config) entity, what is your own bundle?" (not relevant in our case, the config entity types used to store the definitions of configurable fields do not have bundles).

Return value

string|null The bundle the field is defined for, or NULL if it is a base field; i.e., it is not bundle-specific.

Overrides FieldDefinitionInterface::getTargetBundle

1 call to FieldDefinition::getTargetBundle()
FieldDefinition::getUniqueIdentifier in core/lib/Drupal/Core/Field/FieldDefinition.php
Returns a unique identifier for the field.

File

core/lib/Drupal/Core/Field/FieldDefinition.php, line 98

Class

FieldDefinition
A class for defining entity field definitions.

Namespace

Drupal\Core\Field

Code

public function getTargetBundle() {
  return $this->definition['bundle'];
}