if (!
$form_state->
isValueEmpty('custom_entity_id'
)) { $data[$id_key] =
$form_state->
getValue('custom_entity_id'
);
} $entity_storage =
$this->entityTypeManager->
getStorage($form_state->
getValue('config_type'
));
// If an entity ID was not specified, set an error.
if (!
isset($data[$id_key])) { $form_state->
setErrorByName('import',
$this->
t('Missing ID key "@id_key" for this @entity_type import.',
['@id_key' =>
$id_key, '@entity_type' =>
$definition->
getLabel()]));
return;
} $config_name =
$definition->
getConfigPrefix() . '.' .
$data[$id_key];
// If there is an existing entity, ensure matching ID and UUID.
if ($entity =
$entity_storage->
load($data[$id_key])) { $this->configExists =
$entity;
if (!
isset($data['uuid'
])) { $form_state->
setErrorByName('import',
$this->
t('An entity with this machine name already exists but the import did not specify a UUID.'
));
return;
} if ($data['uuid'
] !==
$entity->
uuid()) { $form_state->
setErrorByName('import',
$this->
t('An entity with this machine name already exists but the UUID does not match.'
));
return;
} }