function ContentEntityStorageBase::createEntityFromIds
Same name and namespace in other branches
- 11.x core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php \Drupal\Core\Entity\ContentEntityStorageBase::createEntityFromIds()
Assembles a partial entity structure with initial IDs.
@internal
Parameters
array{entity_id: int|string, revision_id?: int|string, bundle?: string} $entity_identifiers: Array with the following keys:
- entity_id (required),
- revision_id (optional),
- bundle (optional).
Return value
\Drupal\Core\Entity\ContentEntityInterface An entity object, initialized with the provided IDs.
File
-
core/
lib/ Drupal/ Core/ Entity/ ContentEntityStorageBase.php, line 1516
Class
- ContentEntityStorageBase
- Base class for content entity storage handlers.
Namespace
Drupal\Core\EntityCode
public function createEntityFromIds(array $entity_identifiers) : ContentEntityInterface {
$id_properties = [];
if ($id_key = $this->entityType
->getKey('id')) {
$id_properties[$id_key] = $entity_identifiers['entity_id'];
}
if (isset($entity_identifiers['revision_id']) && $revision_key = $this->entityType
->getKey('revision')) {
$id_properties[$revision_key] = $entity_identifiers['revision_id'];
}
if (isset($entity_identifiers['bundle']) && $bundle_key = $this->entityType
->getKey('bundle')) {
$id_properties[$bundle_key] = $entity_identifiers['bundle'];
}
return $this->create($id_properties);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.