ModuleInstaller
class ModuleInstaller implements ModuleInstallerInterface (View source)
Default implementation of the module installer.
It registers the module in config, installs its own configuration, installs the schema, updates the Drupal kernel and more.
We don't inject dependencies yet, as we would need to reload them after each installation or uninstallation of a module. https://www.drupal.org/project/drupal/issues/2350111 for example tries to solve this dilemma.
Properties
| protected ModuleHandlerInterface | $moduleHandler | The module handler. |
|
| protected DrupalKernelInterface | $kernel | The drupal kernel. |
|
| protected string | $root | The app root. |
|
| protected Connection | $connection | The database connection. |
|
| protected UpdateHookRegistry | $updateRegistry | The update registry service. |
|
| protected ModuleUninstallValidatorInterface[] | $uninstallValidators | The uninstall validators. |
Methods
Constructs a new ModuleInstaller instance.
Adds module a uninstall validator.
Installs a given list of modules.
Uninstalls a given list of modules.
Helper method for removing all cache bins registered by a given module.
Updates the kernel module list.
Determines whether a list of modules can be uninstalled.
Creates all tables defined in a module's hook_schema().
Removes all tables defined in a module's hook_schema().
Details
__construct(string $root, ModuleHandlerInterface $module_handler, DrupalKernelInterface $kernel, Connection $connection = NULL, UpdateHookRegistry $update_registry = NULL)
Constructs a new ModuleInstaller instance.
addUninstallValidator(ModuleUninstallValidatorInterface $uninstall_validator)
Adds module a uninstall validator.
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
bool
uninstall(array $module_list, bool $uninstall_dependents = TRUE)
Uninstalls a given list of modules.
protected
removeCacheBins(string $module)
Helper method for removing all cache bins registered by a given module.
protected
updateKernel(string $module_filenames)
Updates the kernel module list.
string[]
validateUninstall(array $module_list)
Determines whether a list of modules can be uninstalled.
protected void
installSchema(string $module)
| internal |
Creates all tables defined in a module's hook_schema().
protected void
uninstallSchema(string $module)
| internal |
Removes all tables defined in a module's hook_schema().