acquia / blt

Acquia's toolset for automating Drupal 8 and 9 development, testing, and deployment.
https://docs.acquia.com/blt/
GNU General Public License v2.0
442 stars 394 forks source link

BLT-5200: Add an option to load settings prior Acquia Cloud settings #4648

Closed vbouchet31 closed 1 year ago

vbouchet31 commented 1 year ago

In some cases (https://support-acquia.force.com/s/article/360049944713-How-to-override-the-default-MySQL-wait-timeout-setting for example), we need to place a setting before the Acquia Cloud settings are loaded.

On project using BLT, the good practice is to not change the sites/default/settings.php file generated by BLT and to use the files automatically loaded by blt.settings.php instead.

Following the good practice, it is currently not possible to do anything before Acquia Cloud settings are loaded

$settings_files = [];

[....]

// Acquia Cloud settings.
if (EnvironmentDetector::isAhEnv()) {
  try {
    if (!EnvironmentDetector::isAcsfEnv()) {
      // Pull in Acquia environment settings file. This eliminates the need to
      // add the Acquia require line in settings.php.
      $settings_files[] = FilePaths::ahSettingsFile(EnvironmentDetector::getAhGroup(), $site_name);
    }
  }
  catch (BltException $e) {
    trigger_error($e->getMessage(), E_USER_WARNING);
  }

  // Store API Keys and things outside of version control.
  // @see settings/sample-secrets.settings.php for sample code.
  // @see https://docs.acquia.com/resource/secrets/#secrets-settings-php-file
  $settings_files[] = EnvironmentDetector::getAhFilesRoot() . '/secrets.settings.php';
  $settings_files[] = EnvironmentDetector::getAhFilesRoot() . "/$site_name/secrets.settings.php";
}