You are here

public function ContentEntityBase::__unset in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Entity/ContentEntityBase.php \Drupal\Core\Entity\ContentEntityBase::__unset()
  2. 10 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 1117

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