public function ForumUninstallValidator::validate in Drupal 10
Same name in this branch
- 10 core/modules/forum/src/ForumUninstallValidator.php \Drupal\forum\ForumUninstallValidator::validate()
- 10 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()
- 9 core/modules/forum/src/ForumUninstallValidator.php \Drupal\forum\ForumUninstallValidator::validate()
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 (!empty($vocabulary) && $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;
}