"Alternatives" allows other modules to declare alternatives to their module dependencies in their *.info file.
Example use case / Usage instructions
The most relevant use case would be for alternative autoloaders like X Autoload vs Registry Autoload.
name = My module
description = Does something.
core = 7.x
dependencies[] = xautoload
; The following will take effect if you enable "alternatives" module.
alternatives[xautoload][] = registry_autoload
; Configuration for registry_autoload if it is used.
; This has nothing to do with "alternatives" module, it just a reminder.
registry_autoload[] = PSR-4
As long as "alternatives" module is disabled, the alternatives[..]
setting in a module's *.info file will do nothing, and only the default dependency ("xautoload" in the example) will be accepted.
If both alternatives
module and registry_autoload
module are enabled, then the dependencies on xautoload
will be replaced with a dependency on registry_autoload
.
Difference to "Any" module
The "Alternatives" module was inspired from a feature request on "Any" module: #2956108: Ideas to simplify "any" module..
With "Alternatives", you only need to add the entry in the *.info file. You don't need hook_requirements() or anything else. You also don't need to require "alternatives".
"Alternatives" always prioritizes the original dependency over its alternatives.
Most users will probably end up installing the original dependency, because this is what they see by default.
"Alternatives" is written from scratch and shares quite little with "Any", but it would probably not exist without it. All ideas came while looking at "any" module. So, thanks to @markcarver for "Any"!
Admin UI / Escaping dependency traps
There is a form at 'admin/modules/alternatives', where you can mark specific modules as "to be ignored".
This way, you can escape a situation where some modules cannot be disabled anymore.
Project information
- Module categories: Developer Tools
- 3 sites report using this module
- Created by donquixote on , updated
- Stable releases for this project are covered by the security advisory policy.
Look for the shield icon below.
Releases
identical with 7.x-1.0-beta2
Development version: 7.x-1.x-dev updated 2 Apr 2018 at 21:43 UTC