Extension depends on another extension

Discussion forum for Extension Writers regarding Extension Development.
Post Reply
User avatar
GanstaZ
Registered User
Posts: 1187
Joined: Wed Oct 11, 2017 10:29 pm
Location: GZOverse

Extension depends on another extension

Post by GanstaZ »

When extension depends on another extension (is available), you can enable it when the other one is enabled. What is the right way to auto disable extension to avoid whatever errors that may occur, if the main extension is disabled by you/someone? I know that $ext_manager is needed for that, but is it done the same way as with notifications or there is a different way?
Usus est magister optimus! phpBB pre-Triton & latest php environment.
When answer lies in the question, question becomes redundant!
User avatar
MattF
Extensions Development Coordinator
Extensions Development Coordinator
Posts: 5861
Joined: Sat Jan 17, 2009 9:37 am
Location: Los Angeles, CA
Name: Matt Friedman

Re: Extension depends on another extension

Post by MattF »

You do not disable another extension. The extension that depends on another one, needs to be well-written with checks and fallbacks for when the main one is not present. Here's one example of such a thing: https://github.com/phpbb-extensions/aut ... recautions
Formerly known as VSEMy ExtensionsPlease do not PM me for support.
User avatar
GanstaZ
Registered User
Posts: 1187
Joined: Wed Oct 11, 2017 10:29 pm
Location: GZOverse

Re: Extension depends on another extension

Post by GanstaZ »

I see.. So it is as simple as drinking a cup of coffee).. Thank you!)
Usus est magister optimus! phpBB pre-Triton & latest php environment.
When answer lies in the question, question becomes redundant!
User avatar
3Di
I've Been Banned!
Posts: 17538
Joined: Mon Apr 04, 2005 11:09 pm
Location: I'm with Ukraine 🇺🇦
Name: Marco
Contact:

Re: Extension depends on another extension

Post by 3Di »

There are extensions that need another extension (father) to work, specifically a precise version of it.

You need to define the installability in ext.php, quite easy if the father got a db/config version, if not you should rely on the composer.json file of it to do your checks, exploring its metadata, have a look here on how I did it in this case (validated):

https://github.com/3D-I/h24as/blob/be0a ... hp#L43-L79

The above extension, once installed, doesn't require further checks in the code, that's another story though.


Instead, if you need to create conditional you can also want to have a look at what I did here, in another validated extension of mine:

define a function which test the ext's enabled status and if there are related db/configs in the DB
https://github.com/3D-I/tpotm/blob/cab5 ... hp#L64-L78

use it
https://github.com/3D-I/tpotm/blob/cab5 ... #L643-L657
🆓 Free support for our extensions also provided here: phpBB Studio
🚀 Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Buy me a coffee -> Image
My development's activity º PhpStorm's proud user º Extensions, Scripts, MOD porting, Update/Upgrades
User avatar
GanstaZ
Registered User
Posts: 1187
Joined: Wed Oct 11, 2017 10:29 pm
Location: GZOverse

Re: Extension depends on another extension

Post by GanstaZ »

Thank you for those awesome examples!)
Usus est magister optimus! phpBB pre-Triton & latest php environment.
When answer lies in the question, question becomes redundant!
Post Reply

Return to “Extension Writers Discussion”