ModuleInstallerInterface.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. namespace Drupal\Core\Extension;
  3. /**
  4. * Provides the installation of modules with creating the db schema and more.
  5. */
  6. interface ModuleInstallerInterface {
  7. /**
  8. * Installs a given list of modules.
  9. *
  10. * Order of events:
  11. * - Gather and add module dependencies to $module_list (if applicable).
  12. * - For each module that is being installed:
  13. * - Invoke hook_module_preinstall().
  14. * - Install module schema and update system registries and caches.
  15. * - Invoke hook_install() and add it to the list of installed modules.
  16. * - Invoke hook_modules_installed().
  17. *
  18. * To install test modules add
  19. * @code
  20. * $settings['extension_discovery_scan_tests'] = TRUE;
  21. * @endcode
  22. * to your settings.php.
  23. *
  24. * @param string[] $module_list
  25. * An array of module names.
  26. * @param bool $enable_dependencies
  27. * (optional) If TRUE, dependencies will automatically be installed in the
  28. * correct order. This incurs a significant performance cost, so use FALSE
  29. * if you know $module_list is already complete.
  30. *
  31. * @return bool
  32. * TRUE if the modules were successfully installed.
  33. *
  34. * @throws \Drupal\Core\Extension\MissingDependencyException
  35. * Thrown when a requested module, or a dependency of one, can not be found.
  36. *
  37. * @see hook_module_preinstall()
  38. * @see hook_install()
  39. * @see hook_modules_installed()
  40. */
  41. public function install(array $module_list, $enable_dependencies = TRUE);
  42. /**
  43. * Uninstalls a given list of modules.
  44. *
  45. * @param string[] $module_list
  46. * The modules to uninstall.
  47. * @param bool $uninstall_dependents
  48. * (optional) If TRUE, dependent modules will automatically be uninstalled
  49. * in the correct order. This incurs a significant performance cost, so use
  50. * FALSE if you know $module_list is already complete.
  51. *
  52. * @return bool
  53. * FALSE if one or more dependencies are missing, TRUE otherwise.
  54. *
  55. * @see hook_module_preuninstall()
  56. * @see hook_uninstall()
  57. * @see hook_modules_uninstalled()
  58. */
  59. public function uninstall(array $module_list, $uninstall_dependents = TRUE);
  60. /**
  61. * Adds module a uninstall validator.
  62. *
  63. * @param \Drupal\Core\Extension\ModuleUninstallValidatorInterface $uninstall_validator
  64. * The uninstall validator to add.
  65. */
  66. public function addUninstallValidator(ModuleUninstallValidatorInterface $uninstall_validator);
  67. /**
  68. * Determines whether a list of modules can be uninstalled.
  69. *
  70. * @param string[] $module_list
  71. * An array of module names.
  72. *
  73. * @return string[]
  74. * An array of reasons the module can not be uninstalled, empty if it can.
  75. */
  76. public function validateUninstall(array $module_list);
  77. }