3

When installing a module how do you require it's extension to be installed at the same time and vice versa?

I did a google search and looked over the docs as well and didn't find anything. That doesn't mean it's not out there. Maybe I wasn't searching for the right terms.

enter image description here

2
  • Which add-on is that? Mar 8, 2013 at 18:05
  • That's Backup Pro. And I'm now seeing exactly what Derek is describing in his answer that came up as I was writing this.
    – Natetronn
    Mar 8, 2013 at 18:16

1 Answer 1

6

This is a bit of an undocumented feature, but it works like this.

In your extension, add a class variable called $required_by, with an array of values:

$required_by = array('module');

('module' is actually the only acceptable array value here, as neither plugins nor accessories have installation routines, which are needed for this to work.)

Note that this does not automatically install (or later, uninstall) your extension. It just makes it clear that you can't install one without the other.

So your module's install() method must also install your extension (basically, everything you'd normally have in your extension's activate_extension() method). Likewise, your module's uninstall() method must contain everything your extension's disable_extension() method would normally have.

(These methods in your extension in this case should just return true.)

Have a look at the bundled Safecracker package for a good example.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.