You are here

public function EntityBase::__construct in Drupal 10

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

Constructs an Entity object.

Parameters

array $values: An array of values to set, keyed by property name. If the entity type has bundles, the bundle key has to be specified.

string $entity_type: The type of the entity to create.

2 methods override EntityBase::__construct()
ConfigEntityBase::__construct in core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php
Constructs an Entity object.
ContentEntityBase::__construct in core/lib/Drupal/Core/Entity/ContentEntityBase.php
Constructs an Entity object.

File

core/lib/Drupal/Core/Entity/EntityBase.php, line 59

Class

EntityBase
Defines a base entity class.

Namespace

Drupal\Core\Entity

Code

public function __construct(array $values, $entity_type) {
  $this->entityTypeId = $entity_type;

  // Set initial values.
  foreach ($values as $key => $value) {
    $this->{$key} = $value;
  }
}