You are here

class UnmetDependenciesException in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Config/UnmetDependenciesException.php \Drupal\Core\Config\UnmetDependenciesException

An exception thrown if configuration has unmet dependencies.

Hierarchy

Expanded class hierarchy of UnmetDependenciesException

4 files declare their use of UnmetDependenciesException
ConfigInstallTest.php in core/modules/config/src/Tests/ConfigInstallTest.php
Contains \Drupal\config\Tests\ConfigInstallTest.
ModulesListConfirmForm.php in core/modules/system/src/Form/ModulesListConfirmForm.php
Contains \Drupal\system\Form\ModulesListConfirmForm.
ModulesListForm.php in core/modules/system/src/Form/ModulesListForm.php
Contains \Drupal\system\Form\ModulesListForm.
ThemeController.php in core/modules/system/src/Controller/ThemeController.php
Contains \Drupal\system\Controller\ThemeController.

File

core/lib/Drupal/Core/Config/UnmetDependenciesException.php, line 16
Contains \Drupal\Core\Config\UnmetDependenciesException.

Namespace

Drupal\Core\Config
View source
class UnmetDependenciesException extends ConfigException {

  /**
   * A list of configuration objects that have unmet dependencies.
   *
   * @var array
   */
  protected $configObjects = [];

  /**
   * The name of the extension that is being installed.
   *
   * @var string
   */
  protected $extension;

  /**
   * Gets the list of configuration objects that have unmet dependencies.
   *
   * @return array
   *   A list of configuration objects that have unmet dependencies.
   */
  public function getConfigObjects() {
    return $this->configObjects;
  }

  /**
   * Gets the name of the extension that is being installed.
   *
   * @return string
   *   The name of the extension that is being installed.
   */
  public function getExtension() {
    return $this->extension;
  }

  /**
   * 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
   *   The name of the extension that is being installed.
   * @param array $config_objects
   *   A list of configuration object names that have unmet dependencies
   *
   * @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', array(
      '@config_names' => implode(', ', $config_objects),
      '@extension' => $extension,
    ));
    $e = new static($message);
    $e->configObjects = $config_objects;
    $e->extension = $extension;
    return $e;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
UnmetDependenciesException::$configObjects protected property A list of configuration objects that have unmet dependencies.
UnmetDependenciesException::$extension protected property The name of the extension that is being installed.
UnmetDependenciesException::create public static function Creates an exception for an extension and a list of configuration objects.
UnmetDependenciesException::getConfigObjects public function Gets the list of configuration objects that have unmet dependencies.
UnmetDependenciesException::getExtension public function Gets the name of the extension that is being installed.
UnmetDependenciesException::getTranslatedMessage public function Gets a translated message from the exception.