You are here

public function ContentEntityBase::__unset in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 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 970
Contains \Drupal\Core\Entity\ContentEntityBase.

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(array());
  }
  else {
    unset($this->values[$name]);
  }
}