public function DatabaseStorageController::create

Implements \Drupal\Core\Entity\EntityStorageControllerInterface::create().

Overrides EntityStorageControllerInterface::create

2 calls to DatabaseStorageController::create()
3 methods override DatabaseStorageController::create()
DatabaseStorageControllerNG::create in drupal/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php
Overrides DatabaseStorageController::create().
FileStorageController::create in drupal/core/modules/file/lib/Drupal/file/FileStorageController.php
Overrides Drupal\Core\Entity\DatabaseStorageController::create().
MenuLinkStorageController::create in drupal/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkStorageController.php
Implements \Drupal\Core\Entity\EntityStorageControllerInterface::create().

File

drupal/core/lib/Drupal/Core/Entity/DatabaseStorageController.php, line 372
Contains \Drupal\Core\Entity\DatabaseStorageController.

Class

DatabaseStorageController
Defines a base entity controller class.

Namespace

Drupal\Core\Entity

Code

public function create(array $values) {
  $class = $this->entityInfo['class'];
  $entity = new $class($values, $this->entityType);

  // Assign a new UUID if there is none yet.
  if ($this->uuidKey && !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);
  return $entity;
}