function FieldItemBase::getEntity

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/Field/FieldItemBase.php \Drupal\Core\Field\FieldItemBase::getEntity()
  2. 10 core/lib/Drupal/Core/Field/FieldItemBase.php \Drupal\Core\Field\FieldItemBase::getEntity()
  3. 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

3 calls to FieldItemBase::getEntity()
DefaultLanguageItem::applyDefaultValue in core/modules/language/src/DefaultLanguageItem.php
Applies the default value.
DefaultLanguageItem::applyDefaultValue in core/modules/language/src/DefaultLanguageItem.php
Applies the default value.
PathItem::postSave in core/modules/path/src/Plugin/Field/FieldType/PathItem.php
Defines custom post-save behavior for field values.

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();
}

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