class ModuleInstaller implements ModuleInstallerInterface (View source)

Provides a proxy class for \Drupal\Core\Extension\ModuleInstaller.

Traits

Provides dependency injection friendly methods for serialization.

Properties

protected array $_serviceIds

An array of service IDs keyed by property name used for serialization.

from  DependencySerializationTrait
protected array $_entityStorages

An array of entity type IDs keyed by the property name of their storages.

from  DependencySerializationTrait
protected string $drupalProxyOriginalServiceId

The id of the original proxied service.

protected ModuleInstaller $service

The real proxied service, after it was lazy loaded.

protected ContainerInterface $container

The service container.

Methods

__sleep()

{@inheritdoc}

__wakeup()

{@inheritdoc}

__construct(ContainerInterface $container, string $drupal_proxy_original_service_id)

Constructs a ProxyClass Drupal proxy object.

object
lazyLoadItself()

Lazy loads the real service from the container.

addUninstallValidator(ModuleUninstallValidatorInterface $uninstall_validator)

Adds module a uninstall validator.

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.

string[]
validateUninstall(array $module_list)

Determines whether a list of modules can be uninstalled.

Details

__sleep()

{@inheritdoc}

__wakeup()

{@inheritdoc}

__construct(ContainerInterface $container, string $drupal_proxy_original_service_id)

Constructs a ProxyClass Drupal proxy object.

Parameters

ContainerInterface $container

The container.

string $drupal_proxy_original_service_id

The service ID of the original service.

protected object lazyLoadItself()

Lazy loads the real service from the container.

Return Value

object

Returns the constructed real service.

addUninstallValidator(ModuleUninstallValidatorInterface $uninstall_validator)

Adds module a uninstall validator.

Parameters

ModuleUninstallValidatorInterface $uninstall_validator

The uninstall validator to add.

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

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

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.