Skip to content

Commit

Permalink
Minor refactor of config settings logic. (#1416)
Browse files Browse the repository at this point in the history
  • Loading branch information
danepowell authored and grasmash committed Apr 21, 2017
1 parent c3b3dd9 commit c92870b
Showing 1 changed file with 11 additions and 32 deletions.
43 changes: 11 additions & 32 deletions settings/config.settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,56 +5,35 @@
$config_directories['sync'] = $dir . "/config/$site_dir";
$split_filename_prefix = 'config_split.config_split';
$split_filepath_prefix = $config_directories['sync'] . '/' . $split_filename_prefix;

$split_envs = array('local', 'dev', 'stage', 'prod', 'ci', 'ah_other');
// Ensure the appropriate config split is enabled.
$config['config_split.config_split.local']['status'] = FALSE;
$config['config_split.config_split.dev']['status'] = FALSE;
$config['config_split.config_split.stage']['status'] = FALSE;
$config['config_split.config_split.prod']['status'] = FALSE;
$config['config_split.config_split.ci']['status'] = FALSE;
$config['config_split.config_split.ah_other']['status'] = FALSE;

foreach ($split_envs as $split_env) {
$config["$split_filename_prefix.$split_env"]['status'] = FALSE;
}
$split = 'none';
// Non-acquia envs.
if ($is_local_env) {
$split = 'local';
if (getenv('TRAVIS') || getenv('PIPELINE_ENV')) {
$split = 'ci';
if (file_exists("$split_filepath_prefix.$split.yml")) {
$config["$split_filename_prefix.$split"]['status'] = TRUE;
}
}
else {
$split = 'local';
if (file_exists("$split_filepath_prefix.$split.yml")) {
$config["$split_filename_prefix.$split"]['status'] = TRUE;
}
}
}
// Acquia only envs.
elseif ($is_ah_env) {
$config_directories['vcs'] = $config_directories['sync'];

$split = 'ah_other';
if ($is_ah_dev_env) {
$split = 'dev';
if (file_exists("$split_filepath_prefix.$split.yml")) {
$config["$split_filename_prefix.$split"]['status'] = TRUE;
}
}
elseif ($is_ah_stage_env) {
$split = 'stage';
if (file_exists("$split_filepath_prefix.$split.yml")) {
$config["$split_filename_prefix.$split"]['status'] = TRUE;
}
}
elseif ($is_ah_prod_env) {
$split = 'prod';
if (file_exists("$split_filepath_prefix.$split.yml")) {
$config["$split_filename_prefix.$split"]['status'] = TRUE;
}
}
else {
$split = 'ah_other';
if (file_exists("$split_filepath_prefix.$split.yml")) {
$config["$split_filename_prefix.$split"]['status'] = TRUE;
}
}
}

if ($split != 'none' && file_exists("$split_filepath_prefix.$split.yml")) {
$config["$split_filename_prefix.$split"]['status'] = TRUE;
}

0 comments on commit c92870b

Please sign in to comment.