diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index 8f8d000..c295ce2 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -17,7 +17,9 @@ use Drupal\Core\Database\DatabaseExceptionWrapper; use Drupal\Core\File\FileSystemInterface; use Drupal\Core\Form\FormState; -use Drupal\Core\Installer\Exception\AlreadyInstalledException; +use Drupal\Core\Installer\Exception\ActiveConfigurationExistsException; +use Drupal\Core\Installer\Exception\DatabaseAlreadyPopulatedException; +use Drupal\Core\Installer\Exception\InstallationTasksCompletedException; use Drupal\Core\Installer\Exception\InstallerException; use Drupal\Core\Installer\Exception\NoProfilesException; use Drupal\Core\Installer\Form\SiteSettingsForm; @@ -514,8 +516,8 @@ function install_begin_request($class_loader, &$install_state) { if (!$install_state['database_verified']) { // Do not install over an existing installation. The call to - // install_verify_database_ready() will throw an AlreadyInstalledException - // if this is the case. + // install_verify_database_ready() will throw an + // DatabaseAlreadyPopulatedException if this is the case. install_verify_database_ready(); } // Verify the last completed task in the database, if there is one. @@ -525,7 +527,8 @@ function install_begin_request($class_loader, &$install_state) { if ($install_state['config_verified'] && empty($task)) { if (count($kernel->getConfigStorage()->listAll())) { $task = NULL; - throw new AlreadyInstalledException($container->get('string_translation')); + $translator = $container->get('string_translation'); + throw new ActiveConfigurationExistsException($translator); } } @@ -1127,7 +1130,8 @@ function install_verify_completed_task() { } if (isset($task)) { if ($task == 'done') { - throw new AlreadyInstalledException(\Drupal::service('string_translation')); + $translator = \Drupal::service('string_translation'); + throw new InstallationTasksCompletedException($translator); } return $task; } @@ -1157,7 +1161,7 @@ function install_verify_database_settings($site_path) { /** * Verify that the database is ready (no existing Drupal installation). * - * @throws \Drupal\Core\Installer\Exception\AlreadyInstalledException + * @throws \Drupal\Core\Installer\Exception\DatabaseAlreadyPopulatedException * Thrown when the database already has a table that would be created by * installing the System module. */ @@ -1177,7 +1181,8 @@ function install_verify_database_ready() { } } if ($existing_install) { - throw new AlreadyInstalledException(\Drupal::service('string_translation')); + $translator = \Drupal::service('string_translation'); + throw new DatabaseAlreadyPopulatedException($translator); } } diff --git a/core/lib/Drupal/Core/Installer/Exception/ActiveConfigurationExistsException.php b/core/lib/Drupal/Core/Installer/Exception/ActiveConfigurationExistsException.php new file mode 100644 index 0000000..e40409a --- /dev/null +++ b/core/lib/Drupal/Core/Installer/Exception/ActiveConfigurationExistsException.php @@ -0,0 +1,20 @@ +stringTranslation = $string_translation; + parent::__construct($string_translation, $this->t('Active configuration already exists.')); + } + +} diff --git a/core/lib/Drupal/Core/Installer/Exception/AlreadyInstalledException.php b/core/lib/Drupal/Core/Installer/Exception/AlreadyInstalledException.php index ca00d0b..bc9af44 100644 --- a/core/lib/Drupal/Core/Installer/Exception/AlreadyInstalledException.php +++ b/core/lib/Drupal/Core/Installer/Exception/AlreadyInstalledException.php @@ -7,26 +7,28 @@ /** * Exception thrown if Drupal is installed already. */ -class AlreadyInstalledException extends InstallerException { +abstract class AlreadyInstalledException extends InstallerException { /** * Constructs a new "already installed" exception. * * @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation * The string translation manager. + * @var string $specific_message + * A specific message exception message. */ - public function __construct(TranslationInterface $string_translation) { - $this->stringTranslation = $string_translation; + public function __construct(TranslationInterface $string_translation, $specific_message = '') { + $title = 'Drupal already installed.'; + + $message = "