[development] module_exists vs. functions_exists?

Aaron Winborn winborn at advomatic.com
Wed Jun 25 16:14:14 UTC 2008


How about:

mymod.info
dependencies[] = taxonomy, someothermod 1.x, urmod
optional_dependencies[] = optionalmod 2.x

mymod.module
$mymod_bar = module_call('optionalmod', 'cool_function', $args);
if (isset($mymod_bar)) {
  $mymod_foo = module_invoke('urmod', 'some_hook', $mymod_bar);
}

Aaron Winborn wrote:
> Doesn't work in many cases. I frequently build modules with optional 
> dependencies. Even with your set up, we're assuming a module's api 
> stays the same within a core version, which is frequently not true.
>
> There's no easy answer for the first case, other than bloating your 
> code with additional drupal_function_exists checks, and the second 
> would require tracking module version (at least its major version).
>
> Earnie Boyd wrote:
>> Quoting Aaron Winborn <winborn at advomatic.com>:
>>
>>> at least document a best practice.
>>>
>>
>> mymod.info
>>  dependencies = urmod
>>
>> mymod.module
>>  $mymod_bar = urmod_foo();
>>
>> Earnie -- http://for-my-kids.com/
>> -- http://give-me-an-offer.com/
>>
>



More information about the development mailing list