[development] Add consistency to node hooks
Henrique Recidive
recidive at gmail.com
Fri Nov 14 17:00:18 UTC 2008
Hello,
a while ago I've submitted a patch to bring more consistency to node
hooks, so they are inline with other drupal data hooks such as
hook_user_*(), hook_file_*().
Node hooks are special, i.e. there are two kinds of node hooks: 1)
hooks for modules which implement node types: hook_load(),
hook_save(), etc and 2) hooks for all modules (those which implement
node types and those which don't): hook_nodeapi_load(),
hook_nodeapi_save().
In my opinion type #1 hooks have meaningless names, since they don't
explicit say they are for extending node functionality. And type #2
hooks are very similar to hook_user_*(), hook_file_*() ones, so why
they have 'nodeapi' in their names, not just 'node'?
Basically what the patch does is changing type #1 hooks so they can be
implemented in the following two ways:
Node type specific:
E.g. poll_node_form_poll()
Node type agnostic:
E.g. poll_node_form()
This way modules which implement node types can have either a) one
hook implementation for *each* node type they implement (the first
case above), or one single hook for *all* node types they implement.
The patch also rename type #2 hooks changing 'nodeapi' to 'node', to
make them inline with other APIs. So e.g. hook_nodeapi_load() becomes
hook_node_load().
What do you guys/gals think?
Please comment on the issue:
http://drupal.org/node/322485
Thanks,
Henrique
More information about the development
mailing list