Hooks


Functions

 module_hook ($module, $hook)
 module_implements ($hook, $sort=FALSE, $refresh=FALSE)
 module_invoke ()
 module_invoke_all ()

Detailed Description

Allow modules to interact with the Drupal core.

Drupal's module system is based on the concept of "hooks". A hook is a PHP function that is named foo_bar(), where "foo" is the name of the module (whose filename is thus foo.module) and "bar" is the name of the hook. Each hook has a defined set of parameters and a specified result type.

To extend Drupal, a module need simply implement a hook. When Drupal wishes to allow intervention from modules, it determines which modules implement a hook and call that hook in all enabled modules that implement it.

The available hooks to implement are explained here in the Hooks section of the developer documentation. The string "hook" is used as a placeholder for the module name is the hook definitions. For example, if the module file is called example.module, then hook_help() as implemented by that module would be defined as example_help().


Function Documentation

module_hook ( module,
hook 
)

Determine whether a module implements a hook.

Parameters:
$module The name of the module (without the .module extension).
$hook The name of the hook (e.g. "help" or "menu").
Returns:
TRUE if the module is both installed and enabled, and the hook is implemented in that module.

Definition at line 379 of file module.inc.

References drupal_function_exists().

Referenced by help_page(), menu_get_active_help(), module_disable(), module_enable(), module_implements(), module_invoke(), module_rebuild_cache(), search_admin_settings(), system_modules(), and system_modules_uninstall().

Here is the call graph for this function:

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

Determine which modules are implementing a hook.

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).
Returns:
An array with the names of the modules which are implementing this hook.

Definition at line 404 of file module.inc.

References module_hook(), module_list(), registry_cache_hook_implementations(), and registry_get_hook_implementations_cache().

Referenced by _db_rewrite_sql(), _element_info(), _theme_build_registry(), drupal_alter(), drupal_get_schema(), help_links_as_list(), menu_router_build(), module_disable(), module_invoke_all(), node_configure(), system_performance_settings(), and watchdog().

Here is the call graph for this function:

module_invoke (  ) 

module_invoke_all (  ) 

Invoke a hook in all enabled modules that implement it.

Parameters:
$hook The name of the hook to invoke.
... Arguments to pass to the hook.
Returns:
An array of return values of the hook implementations. If modules return arrays from their implementations, those are merged into one array.

Definition at line 465 of file module.inc.

References $result, $return, drupal_function_exists(), and module_implements().

Referenced by _drupal_bootstrap_full(), _locale_translate_seek(), actions_delete(), actions_list(), drupal_cron_run(), drupal_flush_all_caches(), drupal_goto(), drupal_page_footer(), drupal_retrieve_form(), file_download(), locale_translate_export_po_form(), locale_translate_export_pot_form(), locale_translate_import_form(), locale_translate_overview_screen(), locale_translate_seek_form(), node_admin_nodes(), node_admin_nodes_submit(), node_type_reset(), search_admin_settings(), system_status(), theme_closure(), trigger_assign(), user_admin_account(), user_admin_account_submit(), and user_logout().

Here is the call graph for this function:


Generated on Mon Jun 2 15:08:56 2008 for SimpleTest by  1.5.5