public function EntityNG::__construct

Overrides Entity::__construct().

Overrides Entity::__construct

File

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

Class

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

Namespace

Drupal\Core\Entity

Code

public function __construct(array $values, $entity_type, $bundle = FALSE) {
  $this->entityType = $entity_type;
  $this->bundle = $bundle ? $bundle : $this->entityType;
  foreach ($values as $key => $value) {

    // If the key matches an existing property set the value to the property
    // to ensure non converted properties have the correct value.
    if (property_exists($this, $key) && isset($value[Language::LANGCODE_DEFAULT])) {
      $this->{$key} = $value[Language::LANGCODE_DEFAULT];
    }
    $this->values[$key] = $value;
  }
  $this
    ->init();
}