Extension depends on another extension

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

Extension depends on another extension

Post by GanstaZ » Thu Mar 15, 2018 6:54 pm

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?
"When answer lies in the question,.. question becomes redundant!"

User avatar
VSE
Extensions Development Coordinator
Extensions Development Coordinator
Posts: 4623
Joined: Sat Jan 17, 2009 9:37 am
Location: Los Angeles, CA
Name: Matt Friedman
Contact:

Re: Extension depends on another extension

Post by VSE » Fri Mar 16, 2018 7:31 am

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
Dictated but not read.
Official phpBB Extensions My Extensions & MODs
Please do not PM me for support.

User avatar
GanstaZ
Registered User
Posts: 358
Joined: Wed Oct 11, 2017 10:29 pm
Location: Zverse

Re: Extension depends on another extension

Post by GanstaZ » Fri Mar 16, 2018 2:12 pm

I see.. So it is as simple as drinking a cup of coffee).. Thank you!)
"When answer lies in the question,.. question becomes redundant!"

User avatar
3Di
Registered User
Posts: 12685
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

Re: Extension depends on another extension

Post by 3Di » Fri Mar 16, 2018 10:27 pm

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
Want to compensate me for my interest? Donate
Please PM me only to request paid works. Thx.
Extensions, Scripts, MOD porting, Update/Upgrades
My development's activity º PhpStorm's proud user

User avatar
GanstaZ
Registered User
Posts: 358
Joined: Wed Oct 11, 2017 10:29 pm
Location: Zverse

Re: Extension depends on another extension

Post by GanstaZ » Sat Mar 17, 2018 1:40 pm

Thank you for those awesome examples!)
"When answer lies in the question,.. question becomes redundant!"

Post Reply

Return to “Extension Writers Discussion”

Who is online

Users browsing this forum: Crizzo, Paul, Toxyy and 4 guests