Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#10 | hook-to-typehook.diff | 8.27 KB | pwolanin |
#8 | hook-to-method.diff | 10.21 KB | pwolanin |
#5 | hook-to-functor_2.diff | 10.97 KB | pwolanin |
#4 | hook-to-nook.diff | 10.7 KB | pwolanin |
hook-to-functor.diff | 10.67 KB | pwolanin | |
Comments
Comment #1
webchickHm. 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.
Comment #2
pwolanin CreditAttribution: pwolanin commentedI 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"
Comment #3
webchickHaha, -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
Comment #4
pwolanin CreditAttribution: pwolanin commentedAre you sure you don't like nook?
Comment #5
pwolanin CreditAttribution: pwolanin commentedslighly better wording, again using "functor"
Comment #6
pwolanin CreditAttribution: pwolanin commentedAlso, 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.
Comment #7
chx CreditAttribution: chx commentedLarry Garfield suggested method instead of hook: method_load, method_view etc. I like that much bet
Comment #8
pwolanin CreditAttribution: pwolanin commentedWorks for me- method is certainly easier to understand than functor...
patch attached
Comment #9
killes@www.drop.org CreditAttribution: killes@www.drop.org commentedI don't think this makes any sense and disapprove of such a change.
Comment #10
pwolanin CreditAttribution: pwolanin commentedhow 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. )
Comment #11
RobRoy CreditAttribution: RobRoy commentedI 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.
Comment #12
walkah CreditAttribution: walkah commented-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.
Comment #13
pwolanin CreditAttribution: pwolanin commentedhow about "typehook_" per the last patch?
Comment #14
RobRoy CreditAttribution: RobRoy commentedIMO it should remain hook_ as per the points above. -1
Comment #15
Gary Feldman CreditAttribution: Gary Feldman commentedHow about leaving it as hook, but adding a section The Two Types of Hooks?
Comment #16
dokumori CreditAttribution: dokumori commentedChanged the component to reflect the new component categorization. See http://drupal.org/node/301443
-dokumori
Comment #17
emmajane CreditAttribution: emmajane commented"the HEAD developer docs" should be in API documentation
Comment #18
pwolanin CreditAttribution: pwolanin commentedThe "Documentation" corresponds to my commits to the docs in CVS, so I think that's the right project.
http://drupal.org/project/cvs/18753
Comment #19
MGParisi CreditAttribution: MGParisi commentedCan I get a Review? Fixed?
Comment #20
jhodgdonThe Documentation project refers to Handbook pages on drupal.org. Project Drupal, component Documentation, refers to doc that ends up on api.drupal.org.
Comment #21
catchMarking duplicate of #441148: Improve node API's developer experience.