XF 2.1 Best way to disable/enable class extensions via an option

GPA-R

Active member
Hi,

I'd like to enable some addon-specific class extensions when the addon is enabled and disable them when it's disabled.

So I added a checkbox in the addon options to control enable/disable.

What is the best way to deal with the class extensions?
a) Create a call back validation function on the "enable" option which will check it's value and accordingly disable the classes?
b) Create an event listener? If yes, which event should I be listening on?
c) other

Thanks
 
Neither.

The best solution is to add the check for the option in the class extension itself, and immediately return the previous value instead of running your code then returning the previous value.
 
  • Like
Reactions: DL6
I'd like to enable some addon-specific class extensions when the addon is enabled and disable them when it's disabled.
The real question is... WHY?

If your add-on is disabled, it's extensions won't run anyway. Either that or I'm not understanding what you're doing. ;)

Unless you're extending another add-on and you want to disable your extensions when the other add-on isn't installed or enabled. But that's not what you asked and they wouldn't run in those cases either.

IE: I have an add-on that extends the XFMG. If XFMG isn't installed, or XFMG is disabled, or MY add-on is disabled, the extensions don't run.
 
Last edited:
Back
Top Bottom