function ModuleInstaller::invoke

Call a procedural hook in an installed module during installation.

Hook_install(), hook_uninstall() etc. will remain procedural.

Parameters

string $module: The module (it can be a profile, too).

string $hook: The name of the hook to invoke.

array $args: Arguments to pass to the hook.

Return value

mixed

5 calls to ModuleInstaller::invoke()
ModuleInstaller::install in core/lib/Drupal/Core/Extension/ModuleInstaller.php
Installs a given list of modules.
ModuleInstaller::installSchema in core/lib/Drupal/Core/Extension/ModuleInstaller.php
Creates all tables defined in a module's hook_schema().
ModuleInstaller::invokeAll in core/lib/Drupal/Core/Extension/ModuleInstaller.php
Call procedural hooks in all installed modules during installation.
ModuleInstaller::uninstall in core/lib/Drupal/Core/Extension/ModuleInstaller.php
Uninstalls a given list of modules.
ModuleInstaller::uninstallSchema in core/lib/Drupal/Core/Extension/ModuleInstaller.php
Removes all tables defined in a module's hook_schema().

File

core/lib/Drupal/Core/Extension/ModuleInstaller.php, line 746

Class

ModuleInstaller
Default implementation of the module installer.

Namespace

Drupal\Core\Extension

Code

protected function invoke(string $module, string $hook, array $args = []) : mixed {
    $function = $module . '_' . $hook;
    return function_exists($function) ? $function(...$args) : NULL;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.