[development] hook_nodeapi()

Larry Garfield larry at garfieldtech.com
Thu Jan 4 03:08:07 UTC 2007


On Wednesday 03 January 2007 7:01 pm, Khalid B wrote:

> For the rename you are proposing, would something like this work?
>
> - move all hook_load() and friends into hook_othernodeapi($op), where $op
> is load, insert,
> delete, ...etc.
> - So, we have one real hook (hook_nodeapi($op)), and one callback
> (hook_othernodeapi($op)).
>
> (of course, othernodeapi has to be something better)
>
> This has the advantage of having only a maximum of two functions per
> module, with ops of course.
> One for node creation modules, and the other the regular nodeapi we know
> today.
>
> How about that?

Except as chx noted, they're not hooks.  Frankly I don't understand the 
obsession with one function with a huge switch statement over multiple 
functions in the first place. :-)

I haven't really had much issue with _load() vs nodeapi('load') et al, to be 
honest.  _load(), etc. map pretty well to pseudo-methods of a node object, 
conceptually.  Many non-OO-syntax systems use that methodology.  _nodeapi() 
is a real hook, and part of Drupal's non-OO-syntax multiple-inheritance 
magic. :-)

Of course, the trick is that it's not just 2 locations where things could 
happen, but 3.  How long ago was it that we debated _load() vs. FAPI, and 
whether or not we needed to keep node_save() because form could just do the 
saving themselves?  (I didn't like that idea either, honestly. <g>)

With CCK and CCK fields migrating into core bit by bit (is that a 4th 
method?), what is the future of value-add modules (event, taxonomy, og, 
etc.)?  What about manually-defined node types?  And if FAPI 3 turns 
everything inside out anyway, what then?  

I don't have code to offer or even answers; I'm just pointing out the scope of 
the issue is more than just hook_nodeapi().

-- 
Larry Garfield			AIM: LOLG42
larry at garfieldtech.com		ICQ: 6817012

"If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it."  -- Thomas 
Jefferson


More information about the development mailing list