class RoleAssignUninstallValidator in RoleAssign 8
Same name in this branch
- 8 src/RoleAssignUninstallValidator.php \Drupal\roleassign\RoleAssignUninstallValidator
- 8 src/ProxyClass/RoleAssignUninstallValidator.php \Drupal\roleassign\ProxyClass\RoleAssignUninstallValidator
Prevents uninstallation of roleassign module by restricted users.
Hierarchy
- class \Drupal\roleassign\RoleAssignUninstallValidator implements ModuleUninstallValidatorInterface uses StringTranslationTrait
Expanded class hierarchy of RoleAssignUninstallValidator
1 string reference to 'RoleAssignUninstallValidator'
1 service uses RoleAssignUninstallValidator
File
- src/
RoleAssignUninstallValidator.php, line 12
Namespace
Drupal\roleassignView source
class RoleAssignUninstallValidator implements ModuleUninstallValidatorInterface {
use StringTranslationTrait;
/**
* Constructs a new RoleAssignUninstallValidator.
*
* @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation
* The string translation service.
*/
public function __construct(TranslationInterface $string_translation) {
$this->stringTranslation = $string_translation;
}
/**
* {@inheritdoc}
*/
public function validate($module) {
$reasons = [];
if ($this
->isCli()) {
return $reasons;
}
if ($module == "roleassign") {
if (!\Drupal::currentUser()
->hasPermission('administer roles')) {
$reasons[] = $this
->t('You are not allowed to disable this module.');
}
}
return $reasons;
}
/**
* Indicates whether this is a CLI request.
*
* @return bool
* TRUE for a cli request, or FALSE.
*/
public function isCli() {
return PHP_SAPI === 'cli';
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RoleAssignUninstallValidator:: |
public | function | Indicates whether this is a CLI request. | |
RoleAssignUninstallValidator:: |
public | function |
Determines the reasons a module can not be uninstalled. Overrides ModuleUninstallValidatorInterface:: |
|
RoleAssignUninstallValidator:: |
public | function | Constructs a new RoleAssignUninstallValidator. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |