Patched to Drupal 8.4.8 level. See https://www.drupal.org/sa-core-2018-004 and patch...
[yaffs-website] / web / core / lib / Drupal / Core / Extension / ModuleUninstallValidatorInterface.php
1 <?php
2
3 namespace Drupal\Core\Extension;
4
5 /**
6  * Common interface for module uninstall validators.
7  *
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.
11  */
12 interface ModuleUninstallValidatorInterface {
13
14   /**
15    * Determines the reasons a module can not be uninstalled.
16    *
17    * Example implementation:
18    * @code
19    * public function validate($module) {
20    *   $entity_types = $this->entityManager->getDefinitions();
21    *   $reasons = array();
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()));
25    *     }
26    *   }
27    *   return $reasons;
28    * }
29    * @endcode
30    *
31    * @param string $module
32    *   A module name.
33    *
34    * @return string[]
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.
38    *
39    * @see template_preprocess_system_modules_uninstall()
40    */
41   public function validate($module);
42
43 }