Tuesday, October 4, 2011

Finding a module list which are having a particular hook in Drupal

Syntax:

module_implements($hook, $sort = FALSE,
$refresh
= FALSE)

Parameters:

$hook   The name of the hook (e.g. "help" or "menu").
$sort     By default, modules are ordered by weight and filename, settings this option to TRUE,  module list will be ordered by module name.
$refresh For internal use only: Whether to force the stored list of hook implementations to be regenerated (such as after enabling a new module, before processing hook_enable).

Example #1

$list = module_implements("cron");
ep($list);

Output #1
Array
(
    [0] => dblog
    [1] => filter
    [2] => node
    [3] => search
    [4] => system
    [5] => update
    [6] => captcha
)
 
Example #2

$list = module_implements("cron", true);
ep($list);

Output #2
Array
(
    [0] => captcha
    [1] => dblog
    [2] => filter
    [3] => node
    [4] => search
    [5] => system
    [6] => update
)

No comments:

Post a Comment

Followers