[development] hook_depend()

Richard Morse remorse at partners.org
Wed May 31 19:19:09 UTC 2006


On May 27, 2006, at 9:20 AM, Doq Doques wrote:

> Hi. What about implementing hook_depend(). I mean module that depends
> on some module (e.g. taxonomy) must define
>
> function modulename_depend() {
>  return array('taxonomy');
> }

What would also be useful, at least potentially, is some way to  
indicate what order hooks should be evaluated in.  Suppose that  
foo.module uses hook_form_alter() to add something to the node  
creation form.  In order to write a module that changes the default  
value of that addition, you need to have the module name come after  
'foo' in the alphabet (presumably in the local LOCALE, but perhaps by  
ASCII order).  It would be nice to be able to have:

function hook_depends() {
	return array('hook_form_alter' => array('foo', 'taxonomy'));
}

This would indicate that this module requires foo and taxonomy, and  
that hook_form_alter should be called after foo and taxonomy's have  
already been called.

If there is a cycle that gets established, you would fall back to the  
current sorting order.

Does this make sense?

Ricky


More information about the development mailing list