[development] Rename *_load and friends

adrian rossouw adrian at bryght.com
Mon Jan 8 15:42:22 UTC 2007


On 07 Jan 2007, at 9:11 AM, Karoly Negyesi wrote:

>> I agree with James on this.  There's something elegantly simple about
>> hook_something turns into module_something.
>
> Problem. hook_load does not turn into module_load any more. It's  
> turned into whatever 'module' is defined in hook_node_info

Personally, I favour load_<something> (where something is either the  
modulename, or modulename_thing).

This can be used in a function called drupal_load('something',  
'parameter', 'parameter'); (which works in almost exactly the same
way we currently do theme functions), But you can also change the  
functions, by changing the data definitions.

This would allow us to hook into the save / load of all our objects.  
A simple example is finally
introducing the top level object/ item type.

Every node/user/term/etc could insert a record into the items table.  
And you could just use load('item', $item_id);
to return the item. You could then relate items to each other,  
instead of having to do the node / user / taxonomy / blah
loading / saving / etc.

With these functions all being in this way, we can make sure the API  
is consistent. All load functions must return the object,
all update functions must take the object as a reference (for the  
other modules to hook into). It's always annoyed me how
node_save and user_save have different function definitions.


More information about the development mailing list