summaryrefslogtreecommitdiffstats
path: root/core/lib/Drupal/Core/Config/UnmetDependenciesException.php
diff options
context:
space:
mode:
Diffstat (limited to 'core/lib/Drupal/Core/Config/UnmetDependenciesException.php')
-rw-r--r--core/lib/Drupal/Core/Config/UnmetDependenciesException.php55
1 files changed, 43 insertions, 12 deletions
diff --git a/core/lib/Drupal/Core/Config/UnmetDependenciesException.php b/core/lib/Drupal/Core/Config/UnmetDependenciesException.php
index c74513c..9ce487b 100644
--- a/core/lib/Drupal/Core/Config/UnmetDependenciesException.php
+++ b/core/lib/Drupal/Core/Config/UnmetDependenciesException.php
@@ -2,7 +2,7 @@
namespace Drupal\Core\Config;
-use Drupal\Component\Utility\SafeMarkup;
+use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\StringTranslation\TranslationInterface;
/**
@@ -13,6 +13,20 @@ class UnmetDependenciesException extends ConfigException {
/**
* A list of configuration objects that have unmet dependencies.
*
+ * The list is keyed by the config object name, and the value is an array of
+ * the missing dependencies:
+ *
+ * @code
+ *
+ * self::configObjects = [
+ * config_object_name => [
+ * 'missing_dependency_1',
+ * 'missing_dependency_2',
+ * ]
+ * ];
+ *
+ * @endcode
+ *
* @var array
*/
protected $configObjects = [];
@@ -28,7 +42,8 @@ class UnmetDependenciesException extends ConfigException {
* Gets the list of configuration objects that have unmet dependencies.
*
* @return array
- * A list of configuration objects that have unmet dependencies.
+ * A list of configuration objects that have unmet dependencies, keyed by
+ * object name, with the value being a list of the unmet dependencies.
*/
public function getConfigObjects() {
return $this->configObjects;
@@ -53,13 +68,11 @@ class UnmetDependenciesException extends ConfigException {
* @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.',
+ return $string_translation->translate(
+ 'Unable to install %extension due to unmet dependencies: %config_names',
[
- '%config_names' => implode(', ', $this->getConfigObjects()),
- '@extension' => $extension,
+ '%config_names' => static::formatConfigObjectList($this->configObjects),
+ '%extension' => $extension,
]
);
}
@@ -70,15 +83,16 @@ class UnmetDependenciesException extends ConfigException {
* @param $extension
* The name of the extension that is being installed.
* @param array $config_objects
- * A list of configuration object names that have unmet dependencies
+ * A list of configuration keyed by configuration name, with unmet
+ * dependencies as the value.
*
* @return \Drupal\Core\Config\PreExistingConfigException
*/
public static function create($extension, array $config_objects) {
- $message = SafeMarkup::format('Configuration objects (@config_names) provided by @extension have unmet dependencies',
+ $message = new FormattableMarkup('Configuration objects provided by %extension have unmet dependencies: %config_names',
array(
- '@config_names' => implode(', ', $config_objects),
- '@extension' => $extension
+ '%config_names' => static::formatConfigObjectList($config_objects),
+ '%extension' => $extension
)
);
$e = new static($message);
@@ -87,4 +101,21 @@ class UnmetDependenciesException extends ConfigException {
return $e;
}
+ /**
+ * Formats a list of configuration objects.
+ *
+ * @param array $config_objects
+ * A list of configuration object names that have unmet dependencies.
+ *
+ * @return string
+ * The imploded config_objects, formatted in an easy to read string.
+ */
+ protected static function formatConfigObjectList(array $config_objects) {
+ $list = [];
+ foreach ($config_objects as $config_object => $missing_dependencies) {
+ $list[] = $config_object . ' (' . implode(', ', $missing_dependencies) . ')';
+ }
+ return implode(', ', $list);
+ }
+
}