Unfortunately this function and module_invoke() do not allow passing variables by reference.
To work around this, you can do something like this:
<?phpforeach (module_implements('my_hook') as $module) { $function = $module . '_my_hook'; $function($var1, $var2);}?>
And, make sure to have the ampersand in the hook declaration:
<?phpfunction my_module_my_hook(&$var1, &$var2) { $var1 = 'do'; $var2 = 'stuff';}?>
If you want to pass things by reference, it's likely that you want to do
<?php $modified_data = drupal_alter('my_type', $data); ?>
instead.http://api.drupal.org/api/drupal/includes!module.inc/function/drupal_alt...
Comments
Pass by reference
PermalinkUnfortunately this function and module_invoke() do not allow passing variables by reference.
To work around this, you can do something like this:
<?phpforeach (module_implements('my_hook') as $module) {
$function = $module . '_my_hook';
$function($var1, $var2);
}
?>
And, make sure to have the ampersand in the hook declaration:
<?phpfunction my_module_my_hook(&$var1, &$var2) {
$var1 = 'do';
$var2 = 'stuff';
}
?>
drupal_alter()?
PermalinkIf you want to pass things by reference, it's likely that you want to do
<?php$modified_data = drupal_alter('my_type', $data);
?>
instead.
http://api.drupal.org/api/drupal/includes!module.inc/function/drupal_alt...