public function EntityNG::__set

Implements the magic method for setting object properties.

Uses default language always.

File

drupal/core/lib/Drupal/Core/Entity/EntityNG.php, line 498
Contains \Drupal\Core\Entity\EntityNG.

Class

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

Namespace

Drupal\Core\Entity

Code

public function __set($name, $value) {

  // Support setting values via property objects.
  if ($value instanceof TypedDataInterface && !$value instanceof EntityInterface) {
    $value = $value
      ->getValue();
  }

  // If this is an entity field, handle it accordingly. We first check whether
  // a field object has been already created. If not, we create one.
  if (isset($this->fields[$name][Language::LANGCODE_DEFAULT])) {
    $this->fields[$name][Language::LANGCODE_DEFAULT]
      ->setValue($value);
  }
  elseif ($this
    ->getPropertyDefinition($name)) {
    $this
      ->getTranslatedField($name, Language::LANGCODE_DEFAULT)
      ->setValue($value);
  }
  else {
    $this->values[$name] = $value;
  }
}