You are here

protected function Tasks::installSettings in MongoDB 8

File

drivers/lib/Drupal/Driver/Database/mongodb/Install/Tasks.php, line 67

Class

Tasks

Namespace

Drupal\Driver\Database\mongodb\Install

Code

protected function installSettings() {
  if (Settings::get('bootstrap_config_storage')) {
    return;
  }
  $conf_path = conf_path(FALSE);
  copy(__DIR__ . '/settings.php', "{$conf_path}/settings.testing.php");
  $settingsfile = "{$conf_path}/settings.php";
  file_put_contents($settingsfile, "include __DIR__ . '/settings.testing.php';\n", FILE_APPEND);

  // Now re-read settings.php.

  /** @var \Drupal\Core\Installer\InstallerKernel $kernel */
  $kernel = \Drupal::service('kernel');
  $class_loader = \Drupal::service('class_loader');
  $site_path = $kernel
    ->getSitePath();
  for ($dir = __DIR__; $dir && !is_dir("{$dir}/core"); $dir = dirname($dir)) {
  }

  // Invalidate settings.php before loading it.
  OpCodeCache::invalidate($settingsfile);

  // Now reload settings.php.
  Settings::initialize($dir, $site_path, $class_loader);

  // And make the next rebuild utilize the new bootstrap config storage.
  $kernel
    ->resetConfigStorage();
}