W3cubDocs

/Drupal 8

protected function ContentEntityStorageBase::doCreate

protected ContentEntityStorageBase::doCreate(array $values)

Performs storage-specific creation of entities.

Parameters

array $values: An array of values to set, keyed by property name.

Return value

\Drupal\Core\Entity\EntityInterface

Overrides EntityStorageBase::doCreate

File

core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php, line 78

Class

ContentEntityStorageBase
Base class for content entity storage handlers.

Namespace

Drupal\Core\Entity

Code

protected function doCreate(array $values) {
  // We have to determine the bundle first.
  $bundle = FALSE;
  if ($this->bundleKey) {
    if (!isset($values[$this->bundleKey])) {
      throw new EntityStorageException('Missing bundle for entity type ' . $this->entityTypeId);
    }
    $bundle = $values[$this->bundleKey];
  }
  $entity = new $this->entityClass(array(), $this->entityTypeId, $bundle);
  $this->initFieldValues($entity, $values);
  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!Entity!ContentEntityStorageBase.php/function/ContentEntityStorageBase::doCreate/8.1.x