Add hook that can prevent installation of modules

Created on 4 March 2016, over 9 years ago
Updated 29 March 2023, about 2 years ago

I have a bunch of modules that provide the same functionality with various differences(for example different provider of some service) and they cannot co-exist because they would collide in certain things.

I was looking at what options are available for an installed module to prevent installation of another module and there are any. The closest one is the hook_module_preinstall but unfortunately it is being called right after the module that is being installed is put into the central module registry so throwing an exception would not work. I would have to manually remove sich module from the registry manually and that does not sound like a good approach at all.

So I think moving invocation of this hook just a few lines sooner would solve this. Or introduce a new type of hook_requirements that would be actually called on installed modules and not on the module that is being installed.

I can even imagine a simple code that could even check for "tags" or some other attribute in the module's info file and prevent installing modules on its own if module with the same tag is already installed. So no custom code would be required from developers.

Example: imagine payment method plugin for payment gateway like Stripe or PayPal or something like that. And you want user to be able to manage his credit cards. Of course you want to have a single place for this so you create s dedicated route at /user/uid/credit-cards. Each provider stores the CC info on their server so you only have the card IDs. Now if you would want to change provider, you cannot migrate those cards to this new provider so user would have to add cards manually again. And if you would have both providers at the same time, that would require separate pages to manage those cards for each user and that is just impossibly bad UX. So you would use one of the provider at any given time, but not both.

✨ Feature request
Status

Active

Version

9.5

Component
BaseΒ  β†’

Last updated about 5 hours ago

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024