public function ForumUninstallValidator::validate in Drupal 9
Same name in this branch
- 9 core/modules/forum/src/ForumUninstallValidator.php \Drupal\forum\ForumUninstallValidator::validate()
- 9 core/modules/forum/src/ProxyClass/ForumUninstallValidator.php \Drupal\forum\ProxyClass\ForumUninstallValidator::validate()
Same name and namespace in other branches
- 8 core/modules/forum/src/ForumUninstallValidator.php \Drupal\forum\ForumUninstallValidator::validate()
- 10 core/modules/forum/src/ForumUninstallValidator.php \Drupal\forum\ForumUninstallValidator::validate()
Determines the reasons a module can not be uninstalled.
Parameters
string $module: A module name.
Return value
string[] An array of reasons the module can not be uninstalled, empty if it can. Each reason should not end with any punctuation since multiple reasons can be displayed together.
Overrides ModuleUninstallValidatorInterface::validate
See also
template_preprocess_system_modules_uninstall()
File
- core/
modules/ forum/ src/ ForumUninstallValidator.php, line 53
Class
- ForumUninstallValidator
- Prevents forum module from being uninstalled whilst any forum nodes exist or there are any terms in the forum vocabulary.
Namespace
Drupal\forumCode
public function validate($module) {
$reasons = [];
if ($module == 'forum') {
if ($this
->hasForumNodes()) {
$reasons[] = $this
->t('To uninstall Forum, first delete all <em>Forum</em> content');
}
$vocabulary = $this
->getForumVocabulary();
if ($this
->hasTermsForVocabulary($vocabulary)) {
if ($vocabulary
->access('view')) {
$reasons[] = $this
->t('To uninstall Forum, first delete all <a href=":url">%vocabulary</a> terms', [
'%vocabulary' => $vocabulary
->label(),
':url' => $vocabulary
->toUrl('overview-form')
->toString(),
]);
}
else {
$reasons[] = $this
->t('To uninstall Forum, first delete all %vocabulary terms', [
'%vocabulary' => $vocabulary
->label(),
]);
}
}
}
return $reasons;
}