[development] Convention for naming contrib hooks?

Larry Garfield larry at garfieldtech.com
Fri Oct 16 05:22:57 UTC 2009

On Thursday 15 October 2009 1:18:27 pm Ken Winters wrote:
> On Oct 15, 2009, at 2:07 PM, Nancy Wichmann wrote:
> > Larry Garfield wrote:
> >> It's generally good practice to prefix a hook with the name of your
> >> module if you're not a core module
> >
> > Gosh, it's kind of my thoughts that if it can't be found with
> > module_invoke_all(), then it's not a "hook" (an API maybe). And
> > module_invoke_all() won't find the function unless it starts with
> > the module
> > name (core or contrib).
> I believe they mean the actual hook name, rather than the
> implementation.  So,
> the implementation should look something like this:
> mymodule_cck_dosomething()
> Where CCK defines the hook cck_dosomething() rather than just
> dosomething().
> - Ken Winters

Yes, what Ken said.  See also: hook_views_data(), hook_panels_plugins(), etc.

Nancy, I actually agree that if it's not intended to be called with 
module_invoke_all() then it's not a hook.  It's a magically named callback, 
with more often than not is a design flaw.  module_invoke() is a bug. :-)

(But THAT's a debate I am putting off until Drupal 8...)

Larry Garfield
larry at garfieldtech.com

More information about the development mailing list