public function ConfigStorageController::create

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

Overrides EntityStorageControllerInterface::create

3 calls to ConfigStorageController::create()
ConfigStorageController::importCreate in drupal/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php
Create configuration upon synchronizing configuration changes.
ShortcutStorageController::create in drupal/core/modules/shortcut/lib/Drupal/shortcut/ShortcutStorageController.php
Overrides \Drupal\config\ConfigStorageController::create().
ViewStorageController::create in drupal/core/modules/views/lib/Drupal/views/ViewStorageController.php
Overrides Drupal\config\ConfigStorageController::create().
2 methods override ConfigStorageController::create()
ShortcutStorageController::create in drupal/core/modules/shortcut/lib/Drupal/shortcut/ShortcutStorageController.php
Overrides \Drupal\config\ConfigStorageController::create().
ViewStorageController::create in drupal/core/modules/views/lib/Drupal/views/ViewStorageController.php
Overrides Drupal\config\ConfigStorageController::create().

File

drupal/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php, line 279
Definition of Drupal\Core\Config\Entity\ConfigStorageController.

Class

ConfigStorageController
Defines the storage controller class for configuration entities.

Namespace

Drupal\Core\Config\Entity

Code

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;
}