function ModuleHandler::reOrderModulesForAlter
Reorder modules for alters.
Parameters
array $modules: A list of modules.
string $hook: The hook being worked on, for example form_alter.
Return value
array The list, potentially reordered and changed by hook_module_implements_alter().
1 call to ModuleHandler::reOrderModulesForAlter()
- ModuleHandler::alter in core/
lib/ Drupal/ Core/ Extension/ ModuleHandler.php - Passes alterable variables to specific hook_TYPE_alter() implementations.
File
-
core/
lib/ Drupal/ Core/ Extension/ ModuleHandler.php, line 475
Class
- ModuleHandler
- Class that manages modules in a Drupal installation.
Namespace
Drupal\Core\ExtensionCode
protected function reOrderModulesForAlter(array $modules, string $hook) : array {
// Order by module order first.
$modules = array_intersect(array_keys($this->moduleList), $modules);
// Alter expects the module list to be in the keys.
$implementations = array_fill_keys($modules, FALSE);
// Let modules adjust the order solely based on the primary hook. This
// ensures the same module order regardless of whether this block
// runs. Calling $this->alter() recursively in this way does not
// result in an infinite loop, because this call is for a single
// $type, so we won't end up in this method again.
$this->alter('module_implements', $implementations, $hook);
return array_keys($implementations);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.