W3cubDocs

/Drupal 8

protected function ConfigEntityStorage::_doCreateFromStorageRecord

protected ConfigEntityStorage::_doCreateFromStorageRecord(array $values, $is_syncing = FALSE)

Helps create a configuration entity from storage values.

Allows the configuration entity storage to massage storage values before creating an entity.

Parameters

array $values: The array of values from the configuration storage.

bool $is_syncing: Is the configuration entity being created as part of a config sync.

Return value

ConfigEntityInterface The configuration entity.

See also

\Drupal\Core\Config\Entity\ConfigEntityStorageInterface::createFromStorageRecord()

\Drupal\Core\Config\Entity\ImportableEntityStorageInterface::importCreate()

File

core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php, line 447

Class

ConfigEntityStorage
Defines the storage class for configuration entities.

Namespace

Drupal\Core\Config\Entity

Code

protected function _doCreateFromStorageRecord(array $values, $is_syncing = FALSE) {
  // Assign a new UUID if there is none yet.
  if ($this->uuidKey && $this->uuidService && !isset($values[$this->uuidKey])) {
    $values[$this->uuidKey] = $this->uuidService->generate();
  }
  $data = $this->mapFromStorageRecords(array($values));
  $entity = current($data);
  $entity->original = clone $entity;
  $entity->setSyncing($is_syncing);
  $entity->enforceIsNew();
  $entity->postCreate($this);

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

}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Config!Entity!ConfigEntityStorage.php/function/ConfigEntityStorage::_doCreateFromStorageRecord/8.1.x