protected function ImportPartialForm::getInitialError in Tome 8
Determines if there is an initial error that should prevent an import.
Return value
\Drupal\Core\StringTranslation\TranslatableMarkup|string An error message, if available.
1 call to ImportPartialForm::getInitialError()
- ImportPartialForm::buildForm in modules/
tome_sync/ src/ Form/ ImportPartialForm.php - Form constructor.
File
- modules/
tome_sync/ src/ Form/ ImportPartialForm.php, line 187
Class
- ImportPartialForm
- Contains a form for performing a partial import.
Namespace
Drupal\tome_sync\FormCode
protected function getInitialError() {
if (!$this->contentHasher
->hashesExist()) {
return $this
->t('No content hashes exist to perform a partial import. Please run a full Tome install and export (i.e. "drush tome:install && drush tome:export"), which will ensure hashes exist in the database and filesystem.');
}
// Inform the user if a config import needs to be made. This has to be done
// before a content import in case bundles or fields change.
// @todo Remove temporary third argument when 8.6.x EOLs.
$storage_comparer = new StorageComparer($this->syncStorage, $this->activeStorage, \Drupal::service('config.manager'));
if (!empty($this->syncStorage
->listAll()) && $storage_comparer
->createChangelist()
->hasChanges()) {
$message = $this
->t('There are configuration changes that need importing.');
$url = Url::fromRoute('config.sync', [], [
'query' => [
'destination' => Url::fromRoute('tome_sync.import_partial')
->toString(),
],
]);
// The config module may not be enabled.
if ($url
->access()) {
$message .= ' ' . $this
->t('Please use the <a href=":url">Config Synchronize form</a>, then return here to import content and files.', [
':url' => $url
->toString(),
]);
}
else {
$message .= ' ' . $this
->t('Please run a partial config import (i.e. "drush config:import --partial"), then return here to import content and files.');
}
return $message;
}
// Prevent the current user from being deleted.
$current_user = $this
->currentUser();
if ($current_user instanceof EntityInterface) {
$user_name = TomeSyncHelper::getContentName($current_user);
if (in_array($user_name, $this->contentHasher
->getChangelist()['deleted'], TRUE)) {
return $this
->t('This import would delete the current user and cannot be performed using the user interface.');
}
}
}