You can expose Acquia environment variables to your Twig templates with a preprocess function using getenv()
:
/**
* Implements template_preprocess_page().
*/
function MYTHEME_preprocess_page(&$variables) {
$variables['my_variable'] = getenv('AH_SITE_ENVIRONMENT');
}
In this example, it adds the {{ my_variable }}
Twig variable which contains the environment the Acquia site loads from.
Note that we are using preprocess_page()
and the AH_SITE_ENVIRONMENT
variable as examples. You would have to replace MYTHEME
with your theme's name, and use the appropriate function and environment variable for your particular use case. See the Drupal API documentation on preprocessing for template files for more details.