diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index 9213469..bc8135f 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -1,6 +1,5 @@ get('string_translation'); - throw new AlreadyInstalledException($translator, - $translator->translate('Configured settings.php already exists.')); + throw new SettingsAlreadyExistsException($translator); } } @@ -491,8 +492,7 @@ function install_begin_request($class_loader, &$install_state) { if (!empty($config)) { $task = NULL; $translator = $container->get('string_translation'); - throw new AlreadyInstalledException($translator, - $translator->translate('Active configuration already exists.')); + throw new ActiveConfigurationExists($translator); } } @@ -1074,8 +1074,7 @@ function install_verify_completed_task() { if (isset($task)) { if ($task == 'done') { $translator = \Drupal::service('string_translation'); - throw new AlreadyInstalledException($translator, - $translator->translate('Installation tasks have already been completed.')); + throw new InstallationTasksCompleted($translator); } return $task; } @@ -1113,8 +1112,7 @@ function install_verify_database_ready() { if ($database = Database::getConnectionInfo()) { if (Database::getConnection()->schema()->tableExists($table)) { $translator = \Drupal::service('string_translation'); - throw new AlreadyInstalledException($translator, - $translator->translate('Database is already populated.')); + throw new DatabaseAlreadyPopulatedException($translator); } } } diff --git a/core/lib/Drupal/Core/Installer/Exception/ActiveConfigurationExists.php b/core/lib/Drupal/Core/Installer/Exception/ActiveConfigurationExists.php new file mode 100644 index 0000000..d210144 --- /dev/null +++ b/core/lib/Drupal/Core/Installer/Exception/ActiveConfigurationExists.php @@ -0,0 +1,26 @@ +specificMessage = 'Active configuration already exists.'; + + parent::__construct($string_translation); + } + +} diff --git a/core/lib/Drupal/Core/Installer/Exception/AlreadyInstalledException.php b/core/lib/Drupal/Core/Installer/Exception/AlreadyInstalledException.php index 4c602e5..e57c165 100644 --- a/core/lib/Drupal/Core/Installer/Exception/AlreadyInstalledException.php +++ b/core/lib/Drupal/Core/Installer/Exception/AlreadyInstalledException.php @@ -12,24 +12,28 @@ /** * Exception thrown if Drupal is installed already. */ -class AlreadyInstalledException extends InstallerException { +abstract class AlreadyInstalledException extends InstallerException { + + /** + * @var string + * A specific message set from a class implementing this Exception. + */ + protected $specificMessage = ''; /** * Constructs a new "already installed" exception. * * @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation * The string translation manager. - * @param string - * Description of why it was determined that Drupal was already installed. */ - public function __construct(TranslationInterface $string_translation, $detail = '') { + public function __construct(TranslationInterface $string_translation) { $this->stringTranslation = $string_translation; - $title = $this->t('Drupal already installed'); + $title = $this->t('Drupal already installed.'); + $message = "