class DatabaseDriverUninstallValidator
Same name in this branch
- 10 core/lib/Drupal/Core/ProxyClass/Extension/DatabaseDriverUninstallValidator.php \Drupal\Core\ProxyClass\Extension\DatabaseDriverUninstallValidator
Same name in other branches
- 9 core/lib/Drupal/Core/ProxyClass/Extension/DatabaseDriverUninstallValidator.php \Drupal\Core\ProxyClass\Extension\DatabaseDriverUninstallValidator
- 9 core/lib/Drupal/Core/Extension/DatabaseDriverUninstallValidator.php \Drupal\Core\Extension\DatabaseDriverUninstallValidator
- 11.x core/lib/Drupal/Core/ProxyClass/Extension/DatabaseDriverUninstallValidator.php \Drupal\Core\ProxyClass\Extension\DatabaseDriverUninstallValidator
- 11.x core/lib/Drupal/Core/Extension/DatabaseDriverUninstallValidator.php \Drupal\Core\Extension\DatabaseDriverUninstallValidator
Ensures installed modules providing a database driver are not uninstalled.
Hierarchy
- class \Drupal\Core\Extension\DatabaseDriverUninstallValidator implements \Drupal\Core\Extension\ModuleUninstallValidatorInterface uses \Drupal\Core\StringTranslation\StringTranslationTrait
Expanded class hierarchy of DatabaseDriverUninstallValidator
1 string reference to 'DatabaseDriverUninstallValidator'
- core.services.yml in core/
core.services.yml - core/core.services.yml
1 service uses DatabaseDriverUninstallValidator
File
-
core/
lib/ Drupal/ Core/ Extension/ DatabaseDriverUninstallValidator.php, line 13
Namespace
Drupal\Core\ExtensionView source
class DatabaseDriverUninstallValidator implements ModuleUninstallValidatorInterface {
use StringTranslationTrait;
/**
* The module extension list.
*
* @var \Drupal\Core\Extension\ModuleExtensionList
*/
protected $moduleExtensionList;
/**
* The database connection.
*
* @var \Drupal\Core\Database\Connection
*/
protected $connection;
/**
* Constructs a new DatabaseDriverUninstallValidator.
*
* @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation
* The string translation service.
* @param \Drupal\Core\Extension\ModuleExtensionList $extension_list_module
* The module extension list.
* @param \Drupal\Core\Database\Connection $connection
* The database connection.
*/
public function __construct(TranslationInterface $string_translation, ModuleExtensionList $extension_list_module, Connection $connection) {
$this->stringTranslation = $string_translation;
$this->moduleExtensionList = $extension_list_module;
$this->connection = $connection;
}
/**
* {@inheritdoc}
*/
public function validate($module) {
$reasons = [];
// @todo Remove the next line of code in
// https://www.drupal.org/project/drupal/issues/3129043.
$this->connection = Database::getConnection();
// When the database driver is provided by a module, then that module
// cannot be uninstalled.
if ($module === $this->connection
->getProvider()) {
$module_name = $this->moduleExtensionList
->get($module)->info['name'];
$reasons[] = $this->t("The module '@module_name' is providing the database driver '@driver_name'.", [
'@module_name' => $module_name,
'@driver_name' => $this->connection
->driver(),
]);
}
return $reasons;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|
DatabaseDriverUninstallValidator::$connection | protected | property | The database connection. | ||
DatabaseDriverUninstallValidator::$moduleExtensionList | protected | property | The module extension list. | ||
DatabaseDriverUninstallValidator::validate | public | function | Determines the reasons a module can not be uninstalled. | Overrides ModuleUninstallValidatorInterface::validate | |
DatabaseDriverUninstallValidator::__construct | public | function | Constructs a new DatabaseDriverUninstallValidator. | ||
StringTranslationTrait::$stringTranslation | protected | property | The string translation service. | 3 | |
StringTranslationTrait::formatPlural | protected | function | Formats a string containing a count of items. | ||
StringTranslationTrait::getNumberOfPlurals | protected | function | Returns the number of plurals supported by a given language. | ||
StringTranslationTrait::getStringTranslation | protected | function | Gets the string translation service. | ||
StringTranslationTrait::setStringTranslation | public | function | Sets the string translation service to use. | 2 | |
StringTranslationTrait::t | protected | function | Translates a string to the current language or to a given language. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.