Get the return value of a hook defined in a module? Is there a way to get the return value of a hook defined in a particular module for eg:

$views_theme_hook = module_invoke('views', 'theme');


By using module_invoke function, I got an array of themes declared in views module. Is this proper way of doing it?

But this function needs arguments for some other hooks for eg: hook_tokens.

How could I get the result for hook_tokens and other similar hooks requiring arguments?
module_invoke() is a very simple function:

function module_invoke($module, $hook) {
  $args = func_get_args();
  // Remove $module and $hook from the arguments.
  unset($args[0], $args[1]);
  if (module_hook($module, $hook)) {
    return call_user_func_array($module . '_' . $hook, $args);
  }
}


As you can see, it passes the arguments straight through to the hook function by way of call_user_func_array().

So, you just need to pass the extra arguments with the call to module_invoke(). For example, to invoke views_block_view() with a specific block delta, you would use:

$block = module_invoke('views', 'block_view', 'some_block_delta');