protected function ContentEntityStorageBase::doCreate in Drupal 10
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php \Drupal\Core\Entity\ContentEntityStorageBase::doCreate()
- 9 core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php \Drupal\Core\Entity\ContentEntityStorageBase::doCreate()
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
1 call to ContentEntityStorageBase::doCreate()
- ContentEntityStorageBase::create in core/
lib/ Drupal/ Core/ Entity/ ContentEntityStorageBase.php - Constructs a new entity object, without permanently saving it.
File
- core/
lib/ Drupal/ Core/ Entity/ ContentEntityStorageBase.php, line 122
Class
- ContentEntityStorageBase
- Base class for content entity storage handlers.
Namespace
Drupal\Core\EntityCode
protected function doCreate(array $values) {
$bundle = $this
->getBundleFromValues($values);
if ($this->bundleKey && !$bundle) {
throw new EntityStorageException('Missing bundle for entity type ' . $this->entityTypeId);
}
$entity_class = $this
->getEntityClass($bundle);
$entity = new $entity_class([], $this->entityTypeId, $bundle);
$this
->initFieldValues($entity, $values);
return $entity;
}