class RequiredModuleUninstallValidator
Same name in this branch
- 11.x core/lib/Drupal/Core/ProxyClass/Extension/RequiredModuleUninstallValidator.php \Drupal\Core\ProxyClass\Extension\RequiredModuleUninstallValidator
Same name in other branches
- 9 core/lib/Drupal/Core/ProxyClass/Extension/RequiredModuleUninstallValidator.php \Drupal\Core\ProxyClass\Extension\RequiredModuleUninstallValidator
- 9 core/lib/Drupal/Core/Extension/RequiredModuleUninstallValidator.php \Drupal\Core\Extension\RequiredModuleUninstallValidator
- 8.9.x core/lib/Drupal/Core/ProxyClass/Extension/RequiredModuleUninstallValidator.php \Drupal\Core\ProxyClass\Extension\RequiredModuleUninstallValidator
- 8.9.x core/lib/Drupal/Core/Extension/RequiredModuleUninstallValidator.php \Drupal\Core\Extension\RequiredModuleUninstallValidator
- 10 core/lib/Drupal/Core/ProxyClass/Extension/RequiredModuleUninstallValidator.php \Drupal\Core\ProxyClass\Extension\RequiredModuleUninstallValidator
- 10 core/lib/Drupal/Core/Extension/RequiredModuleUninstallValidator.php \Drupal\Core\Extension\RequiredModuleUninstallValidator
Ensures that required modules cannot be uninstalled.
Hierarchy
- class \Drupal\Core\Extension\RequiredModuleUninstallValidator implements \Drupal\Core\Extension\ModuleUninstallValidatorInterface uses \Drupal\Core\StringTranslation\StringTranslationTrait
Expanded class hierarchy of RequiredModuleUninstallValidator
File
-
core/
lib/ Drupal/ Core/ Extension/ RequiredModuleUninstallValidator.php, line 11
Namespace
Drupal\Core\ExtensionView source
class RequiredModuleUninstallValidator implements ModuleUninstallValidatorInterface {
use StringTranslationTrait;
/**
* The module extension list.
*
* @var \Drupal\Core\Extension\ModuleExtensionList
*/
protected $moduleExtensionList;
/**
* Constructs a new RequiredModuleUninstallValidator.
*
* @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation
* The string translation service.
* @param \Drupal\Core\Extension\ModuleExtensionList $extension_list_module
* The module extension list.
*/
public function __construct(TranslationInterface $string_translation, ModuleExtensionList $extension_list_module) {
$this->stringTranslation = $string_translation;
$this->moduleExtensionList = $extension_list_module;
}
/**
* {@inheritdoc}
*/
public function validate($module) {
$reasons = [];
$module_info = $this->getModuleInfoByModule($module);
if (!empty($module_info['required'])) {
$reasons[] = $this->t('The @module module is required', [
'@module' => $module_info['name'],
]);
}
return $reasons;
}
/**
* Returns the module info for a specific module.
*
* @param string $module
* The name of the module.
*
* @return array
* The module info, or empty array if that module does not exist.
*/
protected function getModuleInfoByModule($module) {
if ($this->moduleExtensionList
->exists($module)) {
return $this->moduleExtensionList
->get($module)->info;
}
return [];
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|
RequiredModuleUninstallValidator::$moduleExtensionList | protected | property | The module extension list. | ||
RequiredModuleUninstallValidator::getModuleInfoByModule | protected | function | Returns the module info for a specific module. | ||
RequiredModuleUninstallValidator::validate | public | function | Determines the reasons a module can not be uninstalled. | Overrides ModuleUninstallValidatorInterface::validate | |
RequiredModuleUninstallValidator::__construct | public | function | Constructs a new RequiredModuleUninstallValidator. | ||
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.