Skip to content

Instantly share code, notes, and snippets.

@markf3lton
Last active August 19, 2019 18:01
Show Gist options
  • Save markf3lton/d513c84bee6621ee9e82ca72a1cae7c8 to your computer and use it in GitHub Desktop.
Save markf3lton/d513c84bee6621ee9e82ca72a1cae7c8 to your computer and use it in GitHub Desktop.
# From factory-hooks/post-settings-php/search-api-solr.php
<?php
/**
* @file
*
* Used to configure the most appropriate core depending on the environment
* currently in use. Site Factory and the Acquia Connector module vary
* so we need to manually fix it.
*
* Note - Acquia Search always requires fairly new versions of the contributed
* modules in order to run. Please see the docs for what these are today.
*
* @see https://docs.acquia.com/acquia-search/modules
* @see https://docs.acquia.com/acquia-search/multiple-cores/override#code-override
*/
if (isset($_ENV['AH_SITE_ENVIRONMENT'])) {
switch ($_ENV['AH_SITE_ENVIRONMENT']) {
case '01live' :
case '01update' :
$config['acquia_search.settings']['connection_override'] = [
'scheme' => 'https',
'port' => 443,
'host' => 'abc-c123.acquia-search.com',
'index_id' => 'ABC-123',
'derived_key' => 'abc123',
];
break;
case '01test' :
case '01testup' :
$config['acquia_search.settings']['connection_override'] = [
'scheme' => 'https',
'port' => 443,
'host' => 'abc-c123.acquia-search.com',
'index_id' => 'ABC-123.01test.default',
'path' => '/solr/ABC-123.01test.default',
'derived_key' => 'abc123',
];
break;
case '01dev' :
case '01devup' :
$config['acquia_search.settings']['connection_override'] = [
'scheme' => 'https',
'port' => 443,
'host' => 'abc-c123.acquia-search.com',
'index_id' => 'ABC-123.01dev.default',
'path' => '/solr/ABC-123.01dev.default',
'derived_key' => 'abc123',
];
break;
}
// Set site hash dynamically for specific site types so there are no index
// collisions.
if (isset($site_metadata) &&
!empty($site_metadata['site']['profile']) &&
isset($acsf_db_name)) {
$platform_site_types = [
'abc_special',
'abc_other',
'abc_corporate',
];
// Check if this site type is part of the managed platform, and if so set
// it's site_hash. We don't want to interact with profiles unrelated to
// this management paradigm.
if (in_array($site_metadata['site']['profile'], $platform_site_types)) {
$config['search_api_solr.settings']['site_hash'] = $acsf_db_name;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment