Same name and namespace in other branches
  1. 8.9.x 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

1 call to FieldItemBase::getEntity()
FieldItemBase::view in core/lib/Drupal/Core/Field/FieldItemBase.php
Returns a renderable array for a single field item.

File

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

Class

FieldItemBase
An entity field item.

Namespace

Drupal\Core\Field

Code

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