File

Code

functionmodule_implements($hook, $sort = FALSE, $refresh = FALSE) {
static$implementations;
if ($refresh) {
$implementations = array();
return;
}
if (!isset($implementations[$hook])) {
$implementations[$hook] = array();
$list = module_list(FALSE, TRUE, $sort);
foreach ($listas$module) {
if (module_hook($module, $hook)) {
$implementations[$hook][] = $module;
}
}
}
// The explicit cast forces a copy to be made. This is needed because
// $implementations[$hook] is only a reference to an element of
// $implementations and if there are nested foreaches (due to nested node
// API calls, for example), they would both manipulate the same array's
// references, which causes some modules' hooks not to be called.
// See also http://www.zend.com/zend/art/ref-count.php.
return(array)$implementations[$hook];
}