interface ModuleInstallerInterface (View source)

Provides the installation of modules with creating the db schema and more.

Methods

bool
install(array $module_list, bool $enable_dependencies = TRUE)

Installs a given list of modules.

bool
uninstall(array $module_list, bool $uninstall_dependents = TRUE)

Uninstalls a given list of modules.

addUninstallValidator(ModuleUninstallValidatorInterface $uninstall_validator)

Adds module a uninstall validator.

string[]
validateUninstall(array $module_list)

Determines whether a list of modules can be uninstalled.

Details

bool install(array $module_list, bool $enable_dependencies = TRUE)

Installs a given list of modules.

Order of events:

  • Gather and add module dependencies to $module_list (if applicable).
  • For each module that is being installed:
    • Invoke hook_module_preinstall().
    • Install module schema and update system registries and caches.
    • Invoke hook_install() and add it to the list of installed modules.
  • Invoke hook_modules_installed().

To install test modules add

Parameters

array $module_list

An array of module names.

bool $enable_dependencies

(optional) If TRUE, dependencies will automatically be installed in the correct order. This incurs a significant performance cost, so use FALSE if you know $module_list is already complete.

Return Value

bool

TRUE if the modules were successfully installed.

Exceptions

MissingDependencyException
ExtensionNameLengthException

See also

hook_module_preinstall()
hook_install()
hook_modules_installed()

bool uninstall(array $module_list, bool $uninstall_dependents = TRUE)

Uninstalls a given list of modules.

Parameters

array $module_list

The modules to uninstall.

bool $uninstall_dependents

(optional) If TRUE, dependent modules will automatically be uninstalled in the correct order. This incurs a significant performance cost, so use FALSE if you know $module_list is already complete.

Return Value

bool

FALSE if one or more dependencies are missing, TRUE otherwise.

Exceptions

ModuleUninstallValidatorException

See also

hook_module_preuninstall()
hook_uninstall()
hook_modules_uninstalled()

addUninstallValidator(ModuleUninstallValidatorInterface $uninstall_validator)

Adds module a uninstall validator.

Parameters

ModuleUninstallValidatorInterface $uninstall_validator

The uninstall validator to add.

string[] validateUninstall(array $module_list)

Determines whether a list of modules can be uninstalled.

Parameters

array $module_list

An array of module names.

Return Value

string[]

An array of reasons the module can not be uninstalled, empty if it can.