Per a recent discussion on the devel list about the confuncion between node "hooks" (which are only called for the module defning the node type) and normal hooks (called for all modules), came this suggestion from chx:

http://lists.drupal.org/pipermail/development/2007-January/021677.html

Accordingly, a patch is attached for the HEAD developer docs.

If you don't like "functor" then remake the patch with something else ASAP.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

webchick’s picture

Hm. Problem is, this will still show up as "hook" documentation. I wonder if we want a separate area to describe functors... $form_id .'_validate' and such qualify as well, and it would be nice to get those documented too.

pwolanin’s picture

I don't think the form callbacks are ever termed "hooks", are they?

Also, they are still hooks. The suggestion was really just using a different name placeholder to distinguish them from the usual module hooks new developers.

My only other suggestion instead of "functor" would be "nook" = "node hook"

webchick’s picture

Haha, -1 to nook. ;)

Hm. When I was in IRC, I understood the definition of "functor" (the way Drupal's using it) to be "a callback function where the prefix is known and the suffix is one of a select list." So it seems like FAPI callbacks would fall into that too. Not sure though.

chx???? :P

pwolanin’s picture

Title: distinguish the node hooks (functors) from the usual hooks » distinguish the node type hooks from the usual hooks
Status: Active » Needs review
FileSize
10.7 KB

Are you sure you don't like nook?

pwolanin’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
10.97 KB

slighly better wording, again using "functor"

pwolanin’s picture

Also, where is the wording at the top of this page defined: http://api.drupal.org/api/HEAD/group/hooks

There is a typo, and also this will need to be updated to explain functor_ as much or more than the intro to node.php.

chx’s picture

Larry Garfield suggested method instead of hook: method_load, method_view etc. I like that much bet

pwolanin’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
10.21 KB

Works for me- method is certainly easier to understand than functor...

patch attached

killes@www.drop.org’s picture

I don't think this makes any sense and disapprove of such a change.

pwolanin’s picture

FileSize
8.27 KB

how about this patch- it uses the placeholder "typehook_", and adds some other clarifications, but the term "hook" is still used to describe the functions. It makes these functions a little different, but doesn't stray as far from the "hook_" convention.

(If only hook_node_info() used something like "typehook" or "type_hook" instead of "module", I think that would also add greatly to clarifying how this works. )

RobRoy’s picture

I think this may cause more confusion than it is really worth. I agree with killes and walkah; I like the simplicity that new developers know you can always do hook_ -> modulename_ and be okay. If we have hook_ and method_ it will just add another layer, albeit small, to that learning process, but if everyone agrees that it truly would make things clearer then I'm okay with it.

walkah’s picture

-1 . I don't think there's any need for this , and it adds confusion. "method_" doesn't add anything descriptive (any more than our invented "hook"), and documentation lookups will require knowledge of which is intended.

pwolanin’s picture

how about "typehook_" per the last patch?

RobRoy’s picture

IMO it should remain hook_ as per the points above. -1

Gary Feldman’s picture

How about leaving it as hook, but adding a section The Two Types of Hooks?

dokumori’s picture

Project: Documentation » Drupal core
Version: » 7.x-dev
Component: Developer Guide » documentation

Changed the component to reflect the new component categorization. See http://drupal.org/node/301443
-dokumori

emmajane’s picture

"the HEAD developer docs" should be in API documentation

pwolanin’s picture

Project: Drupal core » Documentation
Version: 7.x-dev »
Component: documentation » Other documentation issues

The "Documentation" corresponds to my commits to the docs in CVS, so I think that's the right project.

http://drupal.org/project/cvs/18753

MGParisi’s picture

Version: » 6.x-1.x-dev

Can I get a Review? Fixed?

jhodgdon’s picture

Project: Documentation » Drupal core
Version: 6.x-1.x-dev » 7.x-dev
Component: Other documentation issues » documentation

The Documentation project refers to Handbook pages on drupal.org. Project Drupal, component Documentation, refers to doc that ends up on api.drupal.org.

catch’s picture

Status: Needs review » Closed (duplicate)