protected function WebformSubmissionExportImportImporter::getEntityImportId in Webform 8.5
Same name and namespace in other branches
- 6.x modules/webform_submission_export_import/src/WebformSubmissionExportImportImporter.php \Drupal\webform_submission_export_import\WebformSubmissionExportImportImporter::getEntityImportId()
Get an entity's import internal id.
Parameters
string $entity_type: The entity type.
string $entity_id: The entity id or UUID.
Return value
int|string|null An entity's internal id. NULL if an entity's internal id can't be determined.
2 calls to WebformSubmissionExportImportImporter::getEntityImportId()
- WebformSubmissionExportImportImporter::importEntityReferenceElement in modules/
webform_submission_export_import/ src/ WebformSubmissionExportImportImporter.php - Import entity reference element.
- WebformSubmissionExportImportImporter::importPrepareRecord in modules/
webform_submission_export_import/ src/ WebformSubmissionExportImportImporter.php - Prepare import submission record.
File
- modules/
webform_submission_export_import/ src/ WebformSubmissionExportImportImporter.php, line 1146
Class
- WebformSubmissionExportImportImporter
- Webform submission export import manager.
Namespace
Drupal\webform_submission_export_importCode
protected function getEntityImportId($entity_type, $entity_id) {
if (!$this->entityTypeManager
->hasDefinition($entity_type)) {
return NULL;
}
$entity_storage = $this->entityTypeManager
->getStorage($entity_type);
// Load entity by properties.
if ($entity_type === 'user') {
$properties = [
'uuid',
'mail',
'name',
];
}
else {
$properties = [
'uuid',
];
}
foreach ($properties as $property) {
$entities = $entity_storage
->loadByProperties([
$property => $entity_id,
]);
if ($entities) {
$entity = reset($entities);
return $entity
->id();
}
}
// Load entity by internal id.
$entity = $entity_storage
->load($entity_id);
if ($entity) {
return $entity
->id();
}
return NULL;
}