In the turning point from just using Drupal to -hopefully- start developing modules, I'm not finding some details in the documentation.
There are many hooks like function hook_[hook_name_here] at http://api.drupal.org/api/group/hooks that can be implemented by modules as function [module_name_here]_[hook_name_here], replacing "hook" with the module name, and containing different custom codes. Those module implementations of hooks are called at some points when running Drupal.
My beginner question: Are the codes included in the API hooks (hook_*) only examples for module developers, or are also executed as they are, in some order before or after the module versions of the hooks?
If there is currently any documentation on this point, that I'm being unable to find, please add the URL, or book title, etc. Thank you!
Comments
Digging into the code
I'm now digging into the code, for example module_invoke_all and some functions using this, and it looks like the codes inside hook_* functions at api.drupal.org are just examples, and only module implementations are executed. But I'm not really sure, or whether this is so in all cases, since there not seems to be any documentation on this point.
I hope a developer can confirm or deny this hypothetical hook mechanism. (???)
API hooks
So, no one knows? Are the codes in the API hooks just examples, or are they also executed, perhaps before the module hooks?
Why does it really matter?
Why does it really matter? All you really need to know is that using the hook_[hook_name] convention, your hooks will be executed at the proper time. Even if they are actually called, you would never need to execute them.
But, that being said, no I don't believe they do exist, nor are they executed. They are just models you can use to define your own hook functions within your modules. However, you can define your own hook functions in a module that can be used by other modules to call your hook.
Contact me to contract me for D7 -> D10/11 migrations.
Thank you
Yes, it makes more sense that they are just models.
> Why does it really matter?
Just because Drupal API beginners like me read the hook codes on api.drupal.org and need that some things are done in a different way. So, if those codes were called for example before our hook implementations in modules, we would need to correct their effects with additional code in our module hooks. However, from what you say, this is not necessary:
> no I don't believe they do exist, nor are they executed. They are just models you can use to define your own hook functions within your modules.
Thank you. I think it would be useful to add one or two phrases to http://api.drupal.org/api/group/hooks saying something like:
"The hook codes included here are not part of the Drupal core, they are just models that you can modify. Only the hook functions implemented within modules are executed when running Drupal."