Wie in der ersten Antwort erwähnt, ist
environment_indicator derjenige, den Sie suchen.
Nun, wir verwenden auch die gleiche Art von Entwicklungsmodell. Wenn das Funktionsmodul verwendet wird, können Sie die Einstellungen zur Vereinfachung in eine Datei schreiben. Dadurch wird der Farbwechsel automatisiert.
Befolgen Sie den folgenden Code, der über das Funktionsmodul importiert werden kann.
/**
* Implements hook_default_environment_indicator_environment().
*/
function mymodule_default_environment_indicator_environment() {
$export = array();
$environment = new stdClass();
$environment->disabled = FALSE; /* Edit this to true to make a default environment disabled initially */
$environment->api_version = 1;
$environment->machine = 'live';
$environment->name = 'Live';
$environment->regexurl = 'example.com';
$environment->settings = array(
'color' => '#bb0000',
'text_color' => '#ffffff',
'weight' => '',
'position' => 'top',
'fixed' => 0,
);
$export['live'] = $environment;
$environment = new stdClass();
$environment->disabled = FALSE; /* Edit this to true to make a default environment disabled initially */
$environment->api_version = 1;
$environment->machine = 'staging';
$environment->name = 'Staging';
$environment->regexurl = 'stage.example.com';
$environment->settings = array(
'color' => '#000099',
'text_color' => '#ffffff',
'weight' => '',
'position' => 'top',
'fixed' => 0,
);
$export['staging'] = $environment;
$environment = new stdClass();
$environment->disabled = FALSE; /* Edit this to true to make a default environment disabled initially */
$environment->api_version = 1;
$environment->machine = 'dev';
$environment->name = 'Dev';
$environment->regexurl = 'dev.example.com';
$environment->settings = array(
'color' => '#000066',
'text_color' => '#ffffff',
'weight' => '',
'position' => 'top',
'fixed' => 0,
);
$export['dev'] = $environment;
return $export;
}