You are here

public function ContentEntityBase::__unset in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Entity/ContentEntityBase.php \Drupal\Core\Entity\ContentEntityBase::__unset()
  2. 9 core/lib/Drupal/Core/Entity/ContentEntityBase.php \Drupal\Core\Entity\ContentEntityBase::__unset()

Implements the magic method for unset().

File

core/lib/Drupal/Core/Entity/ContentEntityBase.php, line 1118

Class

ContentEntityBase
Implements Entity Field API specific enhancements to the Entity class.

Namespace

Drupal\Core\Entity

Code

public function __unset($name) {

  // Unsetting a field means emptying it.
  if ($this
    ->hasField($name)) {
    $this
      ->get($name)
      ->setValue([]);
  }
  else {
    unset($this->values[$name]);
  }
}