Skip to content

Instantly share code, notes, and snippets.

@chriscalip
Created August 2, 2017 16:30
Show Gist options
  • Save chriscalip/e02cd6abf21fffd8a913f6e46065a100 to your computer and use it in GitHub Desktop.
Save chriscalip/e02cd6abf21fffd8a913f6e46065a100 to your computer and use it in GitHub Desktop.
Inspired by settings.pantheon.php; the idea is to use settings file to diverge configurations between environments.
<?php
/**
* @file
* Capacitype Overrides for Pantheon environment configuration file.
*
* This enforces logic that for all pantheon environments the following gets enforced :
* a.) Except for live envinroment, sending mail as logs in devel temp directory.
* b.) Search API algolia : assets2algolia & topics2algolia are only enabled on LIVE pantheon envinroments.
* c.) Enforce find-it active search index for live environment only.
* d.) Enforce ask-it active search index for live environment only.
*
*/
/**
* Enforce mail logic.
*
* For all pantheon environments, except live environment, sending mail as logs in devel temp directory.
*
*/
if (isset($_ENV['PANTHEON_ENVIRONMENT']) && $_ENV['PANTHEON_ENVIRONMENT'] !== 'live' ) {
$config['system.mail']['interface']['default'] = 'devel_mail_log';
$config['devel.settings']['debug_mail_directory'] = 'temporary://my-directory';
}
/**
* Enforce Live Search API "search_api.server.algolia_capacitype_server" -- assets2algolia & topics2algolia
* Enforce Dev Search API "search_api.server.algolia_capacitype_server_for_dev" xxassets2algolia & xxtopics2algolia
*
* Only on live pantheon environment that search api (assets2algolia & topics2algolia) are enabled.
* For Non-Live pantheon envinronment the search api (xxassets2algolia & xxtopics2algolia) are enabled
*
*/
if (isset($_ENV['PANTHEON_ENVIRONMENT']) && $_ENV['PANTHEON_ENVIRONMENT'] === 'live' ) {
// $config['search_api.server.algolia_capacitype_server']['status'] = TRUE;
// $config['search_api.index.assets2algolia']['status'] = TRUE;
// $config['search_api.index.topics2algolia']['status'] = TRUE;
}
else {
$config['search_api.server.algolia_capacitype_server_for_dev']['status'] = TRUE;
$config['search_api.index.xxassets2algolia']['status'] = TRUE;
$config['search_api.index.xxtopics2algolia']['status'] = TRUE;
$config['search_api.server.algolia_capacitype_server']['status'] = FALSE;
$config['search_api.index.assets2algolia']['status'] = FALSE;
$config['search_api.index.topics2algolia']['status'] = FALSE;
}
/**
* c.) Enforce find-it active search index for live environment only.
* from find-it active search index, xxassets2algolia, to assets2algolia
* d.) Enforce ask-it active search index for live environment only.
* from ask-it active search index, xxtopics2algolia, to topics2algolia
*
*/
if (isset($_ENV['PANTHEON_ENVIRONMENT']) && $_ENV['PANTHEON_ENVIRONMENT'] !== 'live' ) {
$config['capacitype_search.appsettings']['active_index']['findIt'] = 'xxassets2algolia';
$config['capacitype_search.appsettings']['active_index']['askIt'] = 'xxtopics2algolia';
$config['capacitype_search.appsettings']['active_index']['fitFacets'] = 'xxfacets2algolia';
}
// Fix truster_host_patterns status error
if (isset($_ENV['PANTHEON_ENVIRONMENT'] )) {
if (in_array($_ENV['PANTHEON_ENVIRONMENT'], array('dev', 'test', 'live'))) {
$settings['trusted_host_patterns'][] = "{$_ENV['PANTHEON_ENVIRONMENT']}-{$_ENV['PANTHEON_SITE_NAME']}.getpantheon.io";
$settings['trusted_host_patterns'][] = "{$_ENV['PANTHEON_ENVIRONMENT']}-{$_ENV['PANTHEON_SITE_NAME']}.pantheon.io";
$settings['trusted_host_patterns'][] = "{$_ENV['PANTHEON_ENVIRONMENT']}-{$_ENV['PANTHEON_SITE_NAME']}.pantheonsite.io";
$settings['trusted_host_patterns'][] = "{$_ENV['PANTHEON_ENVIRONMENT']}-{$_ENV['PANTHEON_SITE_NAME']}.panth.io";
# Replace value with custom domain(s) added in the site Dashboard
$settings['trusted_host_patterns'][] = '^.+\.capacitype\.com$';
$settings['trusted_host_patterns'][] = '^capacitype\.com$';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment