Skip to content

Instantly share code, notes, and snippets.

@JeffTomlinson
Last active April 22, 2017 21:59
Show Gist options
  • Save JeffTomlinson/d536e50efa8ef61bf4e226ffbadb4c6b to your computer and use it in GitHub Desktop.
Save JeffTomlinson/d536e50efa8ef61bf4e226ffbadb4c6b to your computer and use it in GitHub Desktop.
Drupal: Set module implementation weight after that of another module
<?php
/**
* Implements hook_module_implements_alter().
*/
function my_module_module_implements_alter(&$implementations, $hook) {
if ($hook === 'form_alter') {
// Implement after simplesamlphp_auth.
if (isset($implementations['simplesamlphp_auth'])) {
$my_module = ['my_module' => $implementations['my_module']];
unset($implementations['nyun_core']);
$offset = array_search('simplesamlphp_auth', array_keys($implementations)) + 1;
$implementations = array_slice($implementations, 0, $offset, TRUE) +
$my_module +
array_slice($implementations, $offset, NULL, TRUE);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment