[development] Rename *_load and friends
Darrel O'Pry
dopry at thing.net
Mon Jan 8 18:27:57 UTC 2007
On Mon, 2007-01-08 at 17:42 +0200, adrian rossouw wrote:
> 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.
Then you could get silly and implement them as singleton's and add
memcached/someother cache support and get a form of persistent data
object in php for drupal.
More information about the development
mailing list