You are here

public function WebformNodeUninstallValidator::validate in Webform 6.x

Same name in this branch
  1. 6.x modules/webform_node/src/WebformNodeUninstallValidator.php \Drupal\webform_node\WebformNodeUninstallValidator::validate()
  2. 6.x modules/webform_node/src/ProxyClass/WebformNodeUninstallValidator.php \Drupal\webform_node\ProxyClass\WebformNodeUninstallValidator::validate()
Same name and namespace in other branches
  1. 8.5 modules/webform_node/src/WebformNodeUninstallValidator.php \Drupal\webform_node\WebformNodeUninstallValidator::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

modules/webform_node/src/WebformNodeUninstallValidator.php, line 40

Class

WebformNodeUninstallValidator
Prevents webform_node module from being uninstalled whilst any webform nodes exist.

Namespace

Drupal\webform_node

Code

public function validate($module) {
  $reasons = [];
  if ($module === 'webform_node') {

    // The webform node type is provided by the Webform node module. Prevent
    // uninstall if there are any nodes of that type.
    if ($this
      ->hasWebformNodes()) {
      $reasons[] = $this
        ->t('To uninstall Webform node, delete all content that has the Webform content type.');
    }
  }
  return $reasons;
}