I'm not looking about how to implement an existing hook, but rather to create a new type of hook. Let's say the hook hook_node_load() exists. I want to create something like hook_node_preload(), that fires before the node is loaded.

I've searched and can't seem to find out where in the Drupal code hooks are being fired. I assume it's something like module_invoke_all() or something like that? But I'm not sure where it's called.

有帮助吗?

解决方案

Drupal hooks are fired all over the place, throughout all of the Drupal process. There isn't one place that calls all of the hooks.

Below is a list of some of the functions from the Drupal core that create hooks:

http://api.drupal.org/api/drupal/includes%21module.inc/function/calls/module_invoke_all/7

In the case of hook_node_load(), it is called from the entity.inc file located at includes/entity.inc, at line 334.

foreach (module_implements($this->entityInfo['load hook']) as $module) {
  call_user_func_array($module . '_' . $this->entityInfo['load hook'], $args);
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top