You are here

public function FieldItemBase::getEntity in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Field/FieldItemBase.php \Drupal\Core\Field\FieldItemBase::getEntity()
  2. 9 core/lib/Drupal/Core/Field/FieldItemBase.php \Drupal\Core\Field\FieldItemBase::getEntity()

Gets the entity that field belongs to.

Return value

\Drupal\Core\Entity\FieldableEntityInterface The entity object.

Overrides FieldItemInterface::getEntity

14 calls to FieldItemBase::getEntity()
ChangedItem::preSave in core/lib/Drupal/Core/Field/Plugin/Field/FieldType/ChangedItem.php
Defines custom presave behavior for field values.
ChangedTestItem::preSave in core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/ChangedTestItem.php
Defines custom presave behavior for field values.
CommentItem::storageSettingsForm in core/modules/comment/src/Plugin/Field/FieldType/CommentItem.php
Returns a form for the storage-level settings.
DefaultLanguageItem::applyDefaultValue in core/modules/language/src/DefaultLanguageItem.php
Applies the default value.
EntityReferenceItem::getSettableOptions in core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php
Returns an array of settable values with labels for display.

... See full list

File

core/lib/Drupal/Core/Field/FieldItemBase.php, line 60

Class

FieldItemBase
An entity field item.

Namespace

Drupal\Core\Field

Code

public function getEntity() {
  return $this
    ->getParent()
    ->getEntity();
}