diff --git a/core/lib/Drupal/Core/Config/ConfigManager.php b/core/lib/Drupal/Core/Config/ConfigManager.php index b4e3909..36238e8 100644 --- a/core/lib/Drupal/Core/Config/ConfigManager.php +++ b/core/lib/Drupal/Core/Config/ConfigManager.php @@ -91,7 +91,7 @@ public function getEntityByConfigName($name) { if ($definition = $this->entityManager->getDefinition($entity_type_id)) { $config_prefix = $this->entityManager->getDefinition($entity_type_id)->getConfigPrefix(); if ($id = substr($name, strlen($config_prefix) + 1)) { - return entity_load($entity_type_id, $id); + return $this->entityManager->getStorage($entity_type_id)->load($id); } } } @@ -209,29 +209,36 @@ public function findConfigEntityDependentsAsEntities($type, array $names) { * {@inheritdoc} */ public function validateConfigEntityDependentsExistence(array $dependencies) { - $return = TRUE; + // Run through all dependency types and check their existence. Fail as soon + // as possible. foreach ($dependencies as $type => $names) { switch ($type) { case 'module': - $return = $return && $this->validateConfigEntityDependentModulesExistence($names); + if (!$this->validateConfigEntityDependentModulesExistence($names)) { + return FALSE; + } break; case 'theme': - $return = $return && $this->validateConfigEntityDependentThemesExistence($names); + if (!$this->validateConfigEntityDependentThemesExistence($names)) { + return FALSE; + } break; case 'entity': - $return = $return && $this->validateConfigEntityDependentEntitiesExistence($names); + if (!$this->validateConfigEntityDependentEntitiesExistence($names)) { + return FALSE; + } break; } } - return $return; + return TRUE; } /** - * Validates modules existence. + * Checks if the given modules exist. * - * @param array $names + * @param string[] $names * Modules names. * @return bool * Whether or not all modules and themes are enabled. @@ -247,9 +254,9 @@ protected function validateConfigEntityDependentModulesExistence(array $names) { } /** - * Validates themes existence. + * Checks if the given themes exist. * - * @param array $names + * @param string[] $names * Themes names. * @return bool * Whether or not all modules and themes are enabled. @@ -266,9 +273,9 @@ protected function validateConfigEntityDependentThemesExistence(array $names) { } /** - * Validates configuration entities existence. + * Checks if the given configuration entities exist. * - * @param array $names + * @param string[] $names * Configuration entities names. * @return bool * Whether or not all configuration entities exist. diff --git a/core/lib/Drupal/Core/Config/ConfigManagerInterface.php b/core/lib/Drupal/Core/Config/ConfigManagerInterface.php index 63fead1..50e9f32 100644 --- a/core/lib/Drupal/Core/Config/ConfigManagerInterface.php +++ b/core/lib/Drupal/Core/Config/ConfigManagerInterface.php @@ -30,7 +30,7 @@ public function getEntityTypeIdByName($name); * The configuration object name. * * @return \Drupal\Core\Config\Entity\ConfigEntityInterface|null - * Returns configuration entity object or NULL if entity doesn't exist. + * Returns configuration entity object or NULL if the entity doesn't exist. */ public function getEntityByConfigName($name); @@ -110,14 +110,18 @@ public function findConfigEntityDependents($type, array $names); public function findConfigEntityDependentsAsEntities($type, array $names); /** - * Validates existence of all given dependencies. + * Validates the existence of all given dependencies. * - * @param array $dependencies - * An array of dependenices to check against. Possible array keys are - * 'module', 'theme' and 'entity'. + * @param array[] $dependencies + * A two-dimensional array of dependenices to check against. All dependecies + * are grouped by type. Possible types are 'module', 'theme' and 'entity'. + * Types correspond to the array keys. + * If type equals 'module' or 'theme' second dimension array should contain + * a list of module names or theme names. If type equals 'entity' second + * dimension array should contain a list of full configuration object names. * * @return bool - * TRUE if all dependents exists, FALSE otherwise. + * TRUE if all dependents exist, FALSE otherwise. */ public function validateConfigEntityDependentsExistence(array $dependencies); diff --git a/core/modules/config/lib/Drupal/config/Form/ConfigSingleImportForm.php b/core/modules/config/lib/Drupal/config/Form/ConfigSingleImportForm.php index 515c090..d1e4c6c 100644 --- a/core/modules/config/lib/Drupal/config/Form/ConfigSingleImportForm.php +++ b/core/modules/config/lib/Drupal/config/Form/ConfigSingleImportForm.php @@ -192,7 +192,7 @@ public function validateForm(array &$form, array &$form_state) { // Validate existence of configuration entity dependents. if (!empty($data['dependencies'])) { if (!$this->configManager->validateConfigEntityDependentsExistence($data['dependencies'])) { - $this->setFormError('import', $form_state, $this->t('Missing dependencies have been found. Please import them first.')); + $this->setFormError('import', $form_state, $this->t('Missing dependencies have been found. Import them first.')); } } diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigSingleImportExportTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigSingleImportExportTest.php index cdab08d..b45086f 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigSingleImportExportTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigSingleImportExportTest.php @@ -114,7 +114,7 @@ public function testImport() { ); // Attempt an import with a missing module dependency. $this->drupalPostForm('admin/config/development/configuration/single/import', $edit, t('Import')); - $this->assertText(t('Missing dependencies have been found. Please import them first.')); + $this->assertText(t('Missing dependencies have been found. Import them first.')); $this->assertNull($storage->load('third')); // Perform an import with a missing theme. @@ -134,7 +134,7 @@ public function testImport() { ); // Attempt an import with a missing theme dependency. $this->drupalPostForm('admin/config/development/configuration/single/import', $edit, t('Import')); - $this->assertText(t('Missing dependencies have been found. Please import them first.')); + $this->assertText(t('Missing dependencies have been found. Import them first.')); $this->assertNull($storage->load('third')); // Perform an import with a missing entity dependency. @@ -154,7 +154,7 @@ public function testImport() { ); // Attempt an import with a missing entity dependency. $this->drupalPostForm('admin/config/development/configuration/single/import', $edit, t('Import')); - $this->assertText(t('Missing dependencies have been found. Please import them first.')); + $this->assertText(t('Missing dependencies have been found. Import them first.')); $this->assertNull($storage->load('third')); // Perform an import with existing dependencies.