hook_module_implements_alter

7 system.api.php hook_module_implements_alter(&$implementations, $hook)
8 system.api.php hook_module_implements_alter(&$implementations, $hook)

Alter the registry of modules implementing a hook.

This hook is invoked during module_implements(). A module may implement this hook in order to reorder the implementing modules, which are otherwise ordered by the module's system weight.

Note that hooks invoked using drupal_alter() can have multiple variations (such as hook_form_alter() and hook_form_FORM_ID_alter()). drupal_alter() will call all such variants defined by a single module in turn. For the purposes of hook_module_implements_alter(), these variants are treated as a single hook. Thus, to ensure that your implementation of hook_form_FORM_ID_alter() is called at the right time, you will have to have to change the order of hook_form_alter() implementation in hook_module_implements_alter().

Parameters

$implementations: An array keyed by the module's name. The value of each item corresponds to a $group, which is usually FALSE, unless the implementation is in a file named $module.$group.inc.

$hook: The name of the module hook being implemented.

Related topics

1 function implements hook_module_implements_alter()

File

modules/system/system.api.php, line 1951
Hooks provided by Drupal core and the System module.

Code

<?php
function hook_module_implements_alter(&$implementations, $hook) {
  if ($hook == 'rdf_mapping') {
    // Move my_module_rdf_mapping() to the end of the list. module_implements()
    // iterates through $implementations with a foreach loop which PHP iterates
    // in the order that the items were added, so to move an item to the end of
    // the array, we remove it and then add it.
    $group = $implementations['my_module'];
    unset($implementations['my_module']);
    $implementations['my_module'] = $group;
  }
}
?>

Comments

Form alter?

Anyone know if this works with form_alter or form_FORM_ID_alter?

Not yet

It doesn't, but it should. http://drupal.org/node/765860 is the issue tracking that.

Disable?

Can I disable outer (used in another module) hooks using the hook?

I mean simply unset($implementations['another_module']).

Yes you can

Yes you can. If you would like to disable only specific hooks, this is how you'd do it:

<?php
 
if (in_array($hook, array('node_insert', 'node_update', 'node_delete'))) {
    unset(
$implementations['another_module']);
  }
?>

Thanks.

Thanks.

.

.

Login or register to post comments