3 namespace Drupal\Core\Extension;
6 * Common interface for module uninstall validators.
8 * A module uninstall validator must implement this interface and be defined in
9 * a Drupal @link container service @endlink that is tagged
10 * module_install.uninstall_validator.
12 interface ModuleUninstallValidatorInterface {
15 * Determines the reasons a module can not be uninstalled.
17 * Example implementation:
19 * public function validate($module) {
20 * $entity_types = $this->entityManager->getDefinitions();
22 * foreach ($entity_types as $entity_type) {
23 * if ($module == $entity_type->getProvider() && $entity_type instanceof ContentEntityTypeInterface && $this->entityManager->getStorage($entity_type->id())->hasData()) {
24 * $reasons[] = $this->t('There is content for the entity type: @entity_type', array('@entity_type' => $entity_type->getLabel()));
31 * @param string $module
35 * An array of reasons the module can not be uninstalled, empty if it can.
36 * Each reason should not end with any punctuation since multiple reasons
37 * can be displayed together.
39 * @see template_preprocess_system_modules_uninstall()
41 public function validate($module);