diff --git a/core/lib/Drupal/Core/Config/ConfigInstaller.php b/core/lib/Drupal/Core/Config/ConfigInstaller.php index 075b656..7bd813d 100644 --- a/core/lib/Drupal/Core/Config/ConfigInstaller.php +++ b/core/lib/Drupal/Core/Config/ConfigInstaller.php @@ -412,9 +412,9 @@ public function checkConfigurationToInstall($type, $name) { // Install profiles can not have config clashes. Configuration that // has the same name as a module's configuration will be used instead. if ($name != $this->drupalGetProfile()) { - // Validate default configuration of this module. Bail if unable to - // install. Should not continue installing more modules because those - // may depend on this one. + // Throw an exception if the module being installed contains configuration + // that already exits. Additionally, can not continue installing more + // modules because those may depend on the current module being installed. $existing_configuration = $this->findPreExistingConfiguration($type, $name, $enabled_extensions); if (!empty($existing_configuration)) { throw PreExistingConfigException::create($name, $existing_configuration); diff --git a/core/lib/Drupal/Core/Config/UnmetDependenciesException.php b/core/lib/Drupal/Core/Config/UnmetDependenciesException.php index 219ea62..db7ad9c 100644 --- a/core/lib/Drupal/Core/Config/UnmetDependenciesException.php +++ b/core/lib/Drupal/Core/Config/UnmetDependenciesException.php @@ -8,6 +8,7 @@ namespace Drupal\Core\Config; use Drupal\Component\Utility\String; +use Drupal\Core\StringTranslation\TranslationInterface; /** * An exception thrown if configuration has unmet dependencies. @@ -49,6 +50,26 @@ public function getExtension() { } /** + * Gets a translated message from the exception. + * + * @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation + * The string translation service. + * + * @return string + */ + public function getTranslatedMessage(TranslationInterface $string_translation, $extension) { + return $string_translation->formatPlural( + count($this->getConfigObjects()), + 'Unable to install @extension, %config_names has unmet dependencies.', + 'Unable to install @extension, %config_names have unmet dependencies.', + [ + '%config_names' => implode(', ', $this->getConfigObjects()), + '@extension' => $extension, + ] + ); + } + + /** * Creates an exception for an extension and a list of configuration objects. * * @param $extension diff --git a/core/modules/config/src/Tests/ConfigInstallTest.php b/core/modules/config/src/Tests/ConfigInstallTest.php index 2da9e53..4cbc984 100644 --- a/core/modules/config/src/Tests/ConfigInstallTest.php +++ b/core/modules/config/src/Tests/ConfigInstallTest.php @@ -48,11 +48,8 @@ function testModuleInstallation() { $this->assertFalse(\Drupal::service('config.typed')->hasConfigSchema('config_schema_test.schema_in_install'), 'Configuration schema for config_schema_test.schema_in_install does not exist.'); // Install the test module. - $this->enableModules(array('config_test', 'config_schema_test')); - $this->installConfig(array('config_test', 'config_schema_test')); - - // After module installation the new schema should exist. - $this->assertTrue(\Drupal::service('config.typed')->hasConfigSchema('config_schema_test.schema_in_install'), 'Configuration schema for config_schema_test.schema_in_install exists.'); + $this->enableModules(array('config_test')); + $this->installConfig(array('config_test')); // Verify that default module config exists. \Drupal::configFactory()->reset($default_config); @@ -71,6 +68,13 @@ function testModuleInstallation() { $this->assertFalse(isset($GLOBALS['hook_config_test']['predelete'])); $this->assertFalse(isset($GLOBALS['hook_config_test']['delete'])); + // Install the schema test module. + $this->enableModules(array('config_schema_test')); + $this->installConfig(array('config_schema_test')); + + // After module installation the new schema should exist. + $this->assertTrue(\Drupal::service('config.typed')->hasConfigSchema('config_schema_test.schema_in_install'), 'Configuration schema for config_schema_test.schema_in_install exists.'); + // Ensure that data type casting is applied during config installation. $config = $this->config('config_schema_test.schema_in_install'); $this->assertIdentical($config->get('integer'), 1); diff --git a/core/modules/system/src/Controller/ThemeController.php b/core/modules/system/src/Controller/ThemeController.php index 15af689..d82f908 100644 --- a/core/modules/system/src/Controller/ThemeController.php +++ b/core/modules/system/src/Controller/ThemeController.php @@ -146,18 +146,7 @@ public function install(Request $request) { ); } catch (UnmetDependenciesException $e) { - $config_objects = $e->getConfigObjects(); - drupal_set_message( - $this->formatPlural( - count($config_objects), - 'Unable to install @extension, %config_names has unmet dependencies.', - 'Unable to install @extension, %config_names have unmet dependencies.', - array( - '%config_names' => implode(', ', $config_objects), - '@extension' => $theme, - )), - 'error' - ); + drupal_set_message($e->getTranslatedMessage($this->getStringTranslation(), $theme), 'error'); } return $this->redirect('system.themes_page'); diff --git a/core/modules/system/src/Form/ModulesListConfirmForm.php b/core/modules/system/src/Form/ModulesListConfirmForm.php index 0af7674..5449b41 100644 --- a/core/modules/system/src/Form/ModulesListConfirmForm.php +++ b/core/modules/system/src/Form/ModulesListConfirmForm.php @@ -178,16 +178,8 @@ public function submitForm(array &$form, FormStateInterface $form_state) { return; } catch (UnmetDependenciesException $e) { - $config_objects = $e->getConfigObjects(); drupal_set_message( - $this->formatPlural( - count($config_objects), - 'Unable to install @extension, %config_names has unmet dependencies.', - 'Unable to install @extension, %config_names have unmet dependencies.', - array( - '%config_names' => implode(', ', $config_objects), - '@extension' => $this->modules['install'][$e->getExtension()], - )), + $e->getTranslatedMessage($this->getStringTranslation(), $this->modules['install'][$e->getExtension()]), 'error' ); return; diff --git a/core/modules/system/src/Form/ModulesListForm.php b/core/modules/system/src/Form/ModulesListForm.php index 122f7b2..90a6e9f 100644 --- a/core/modules/system/src/Form/ModulesListForm.php +++ b/core/modules/system/src/Form/ModulesListForm.php @@ -538,16 +538,8 @@ public function submitForm(array &$form, FormStateInterface $form_state) { return; } catch (UnmetDependenciesException $e) { - $config_objects = $e->getConfigObjects(); drupal_set_message( - $this->formatPlural( - count($config_objects), - 'Unable to install @extension, %config_names has unmet dependencies.', - 'Unable to install @extension, %config_names have unmet dependencies.', - array( - '%config_names' => implode(', ', $config_objects), - '@extension' => $modules['install'][$e->getExtension()], - )), + $e->getTranslatedMessage($this->getStringTranslation(), $modules['install'][$e->getExtension()]), 'error' ); return;