function EntityBase::getTypedData

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/Entity/EntityBase.php \Drupal\Core\Entity\EntityBase::getTypedData()
  2. 10 core/lib/Drupal/Core/Entity/EntityBase.php \Drupal\Core\Entity\EntityBase::getTypedData()
  3. 9 core/lib/Drupal/Core/Entity/EntityBase.php \Drupal\Core\Entity\EntityBase::getTypedData()
  4. 8.9.x core/lib/Drupal/Core/Entity/EntityBase.php \Drupal\Core\Entity\EntityBase::getTypedData()

Attributes

#[\NoDiscard]

Return value

\Drupal\Core\TypedData\ComplexDataInterface The typed data object for this entity.

Overrides EntityInterface::getTypedData

File

core/lib/Drupal/Core/Entity/EntityBase.php, line 629

Class

EntityBase
Defines a base entity class.

Namespace

Drupal\Core\Entity

Code

public function getTypedData() {
  if ($this->typedData instanceof \WeakReference) {
    $return = $this->typedData
      ->get();
    if ($return !== NULL) {
      return $return;
    }
  }
  $class = $this->getTypedDataClass();
  $return = $class::createFromEntity($this);
  $this->typedData = \WeakReference::create($return);
  return $return;
}

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