Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ModuleInstallerInterface.php

interface ModuleInstallerInterface

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

Hierarchy

  • interface \Drupal\Core\Extension\ModuleInstallerInterface

Expanded class hierarchy of ModuleInstallerInterface

All classes that implement ModuleInstallerInterface

9 files declare their use of ModuleInstallerInterface
ConfigImporter.php in core/lib/Drupal/Core/Config/ConfigImporter.php
ConfigSingleImportForm.php in core/modules/config/src/Form/ConfigSingleImportForm.php
ConfigSync.php in core/modules/config/src/Form/ConfigSync.php
ModulesListConfirmForm.php in core/modules/system/src/Form/ModulesListConfirmForm.php
ModulesListForm.php in core/modules/system/src/Form/ModulesListForm.php

... See full list

File

core/lib/Drupal/Core/Extension/ModuleInstallerInterface.php, line 8

Namespace

Drupal\Core\Extension
View source
interface ModuleInstallerInterface {
    
    /**
     * 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
     * @code
     * $settings['extension_discovery_scan_tests'] = TRUE;
     * @endcode
     * to your settings.php.
     *
     * @param string[] $module_list
     *   An array of module names.
     * @param 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 bool
     *   TRUE if the modules were successfully installed.
     *
     * @throws \Drupal\Core\Extension\MissingDependencyException
     *   Thrown when a requested module, or a dependency of one, can not be found.
     *
     * @throws \Drupal\Core\Extension\ExtensionNameLengthException
     *   Thrown when the extension's name is longer than
     *   DRUPAL_EXTENSION_NAME_MAX_LENGTH.
     *
     * @throws \Drupal\Core\Extension\ExtensionNameReservedException
     *   Thrown when a module's name is already used by an installed theme.
     *
     * @see hook_module_preinstall()
     * @see hook_install()
     * @see hook_modules_installed()
     */
    public function install(array $module_list, $enable_dependencies = TRUE);
    
    /**
     * Uninstalls a given list of modules.
     *
     * @param string[] $module_list
     *   The modules to uninstall.
     * @param 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 bool
     *   FALSE if one or more dependencies are missing, TRUE otherwise.
     *
     * @throws \Drupal\Core\Extension\ModuleUninstallValidatorException
     *   Thrown when validation prevented the module from being uninstalled.
     *
     * @see hook_module_preuninstall()
     * @see hook_uninstall()
     * @see hook_modules_uninstalled()
     */
    public function uninstall(array $module_list, $uninstall_dependents = TRUE);
    
    /**
     * Adds a module uninstall validator.
     *
     * @param \Drupal\Core\Extension\ModuleUninstallValidatorInterface $uninstall_validator
     *   The uninstall validator to add.
     *
     * @deprecated in drupal:11.1.0 and is removed from drupal:12.0.0. Inject
     *   the uninstall validators into the constructor instead.
     *
     * @see https://www.drupal.org/node/3432595
     */
    public function addUninstallValidator(ModuleUninstallValidatorInterface $uninstall_validator);
    
    /**
     * Determines whether a list of modules can be uninstalled.
     *
     * @param string[] $module_list
     *   An array of module names.
     *
     * @return string[]
     *   An array of reasons the module can not be uninstalled, empty if it can.
     */
    public function validateUninstall(array $module_list);

}

Members

Title Sort descending Deprecated Modifiers Object type Summary Overrides
ModuleInstallerInterface::addUninstallValidator Deprecated public function Adds a module uninstall validator. 2
ModuleInstallerInterface::install public function Installs a given list of modules. 2
ModuleInstallerInterface::uninstall public function Uninstalls a given list of modules. 2
ModuleInstallerInterface::validateUninstall public function Determines whether a list of modules can be uninstalled. 2

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal