Great module!.. Well written and easy to work with code, and delivers very simple and seamless functionality.
Here is a patch to integrate environment indicator with the environment module.
Skip to #4 and use this patch environment_integration_1.1_0.patch
If the environment module is installed and enabled, this patch adds a third radio button to the Enabled/Disabled radios: 'Integrate with environment module'
When in integration mode, if the environment module sets its environment as 'production' environment indicator functions as though disabled.
When environment is set to 'development' the $environment variable is put in the display text, in place of the default 'ENVIRONMENT INDICATOR' text. The user can override this with their own text and include an %env% token in which to insert the environment variable.
Other modules may also set the environment variable and these integrate seemlessly as it just inserts the value of the environment variable into the text string.
In this way, in our deployment environment, where we make heavy use of the environment variable. All we have to do is install environment indicator and set its radio to 'Integrate with environment module'. And the rest 'just works'.
Comment | File | Size | Author |
---|---|---|---|
#4 | environment_integration_1.1.patch | 5.97 KB | thursday_bw |
environment_integration.patch | 5.92 KB | thursday_bw |
Comments
Comment #1
Grayside CreditAttribution: Grayside commentedHi Bevan, I was just in here checking on something for a query in Environment module about integration here #1347078: How to use Environment
I originally wrote #986902: Context Integration to facilitate integration with Environment. It does require Context module to be installed. Just an FYI, I leave it to the EI maintainer to decide what he cares to do ;)
Comment #2
thursday_bw CreditAttribution: thursday_bw commentedI have noticed to minor issues with the environment_integration.patch
* If environment module integration is enabled and the environment variable is not set, in settings.php or in drupal variables then the indicator text is empty
* the patch makes use of variable_get a couple of times, and doesn't supply the default value as the second argument thus generating php warnings.
I'll see if I can get around to create a better patch
Comment #3
mrfelton CreditAttribution: mrfelton commentedComment #4
thursday_bw CreditAttribution: thursday_bw commentedpatch including fixes to issues in comment #2
Comment #5
mrfelton CreditAttribution: mrfelton commentedComment #6
garphy CreditAttribution: garphy commentedIsn't the proposed patch in #4 missing the hook_environment_switch() ?
The enabled state and the displayed text could be updated only on environment switches, leaving the original hook_init() logic untouched.
Comment #7
garphy CreditAttribution: garphy commentedBTW, to clarify : patch works for me. Just wondering if the extra bit in hook_init() is more elegant that integrate through environment hooks.
Comment #8
mrfelton CreditAttribution: mrfelton commentedConceptually, I really like the idea behind this, although there are some issues with the implementation:
Firstly, it should be written for Drupal 7 first ;)
This references admin/user/permissions which does not exist in Drupal 7 (should be admin/people/permissions).
When there were just 2 settings, 1 and 0 was ok. The reason I used
? '1' : '0',
was to allow people to also use a value of TRUE in settings.php to enable. However, this introduces a 3rd option. With three options (there could be more in the future), I would rather this used defined values, eg:However, thinking about this more, your third status is really not a status at all, it is a mode that controls the status. We still really have only 2 states - enabled or disabled. So how about we leave the states as they are, and add another variable called
environment_indicator_mode
with values of 'default' and 'environment', and this would then be used to override the status based on the environment when set to 'environment'.Might be better to use
environment_current()
to find out the current environment rather than a direct call tovariable_get
.How come you are only performing the string replacement if the text has not been set in settings.php? What about the case where someone wants to integrate with environment, but also override the text in settings.php? For example, on my local host I might want the text to read "Tom's Local (%env%)", and not just the name of the environment so I should be able to set that in settings.php. Also, we should probably show the label of the environment rather than the machine name. This can be found out with a call to
environment_environment()
Comment #8.0
mrfelton CreditAttribution: mrfelton commentedFixes to patch
Comment #9
thursday_bw CreditAttribution: thursday_bw at Catalyst IT commentedI figure, it's been 3 years and I have clearly dropped the ball on this one.
So here is a comment that is nothing more than a first step to getting around to pulling this patch up to speed.