Implements Drupal\Core\Entity\EntityStorageControllerInterface::create().
Overrides EntityStorageControllerInterface::create
public function create(array $values) {
$class = $this->entityInfo['class'];
// Set default language to site default if not provided.
$values += array(
'langcode' => language_default()->langcode,
);
$entity = new $class($values, $this->entityType);
// Mark this entity as new, so isNew() returns TRUE. This does not check
// whether a configuration entity with the same ID (if any) already exists.
$entity
->enforceIsNew();
// Assign a new UUID if there is none yet.
if (!isset($entity->{$this->uuidKey})) {
$uuid = new Uuid();
$entity->{$this->uuidKey} = $uuid
->generate();
}
// Modules might need to add or change the data initially held by the new
// entity object, for instance to fill-in default values.
$this
->invokeHook('create', $entity);
// Default status to enabled.
if (!empty($this->statusKey) && !isset($entity->{$this->statusKey})) {
$entity->{$this->statusKey} = TRUE;
}
return $entity;
}