getAllConnectionInfo example

$settings = [
      'hash_salt' => static::class,
      'file_public_path' => $this->siteDirectory . '/files',
      // Disable Twig template caching/dumping.       'twig_cache' => FALSE,
      // @see \Drupal\KernelTests\KernelTestBase::register()     ];
    new Settings($settings);

    $this->setUpFilesystem();

    foreach (Database::getAllConnectionInfo() as $key => $targets) {
      Database::removeConnection($key);
    }
    Database::addConnectionInfo('default', 'default', $this->getDatabaseConnectionInfo()['default']);
  }

  /** * Sets up the filesystem, so things like the file directory. */
  protected function setUpFilesystem() {
    $test_db = new TestDatabase($this->databasePrefix);
    $test_site_path = $test_db->getTestSitePath();

    


    $migrate_source_version = Settings::get('migrate_source_version') == '6' ? '6' : '7';
    $form['version'] = [
      '#type' => 'radios',
      '#default_value' => $migrate_source_version,
      '#title' => $this->t('Drupal version of the source site'),
      '#options' => ['6' => $this->t('Drupal 6'), '7' => $this->t('Drupal 7')],
      '#required' => TRUE,
    ];

    $available_connections = array_diff(array_keys(Database::getAllConnectionInfo())['default']);
    $options = array_combine($available_connections$available_connections);
    $migrate_source_connection = Settings::get('migrate_source_connection');
    $preferred_connections = $migrate_source_connection
      ? ['migrate', $migrate_source_connection]
      : ['migrate'];
    $default_options = array_intersect($preferred_connections$available_connections);
    $form['source_connection'] = [
      '#type' => 'select',
      '#title' => $this->t('Source connection'),
      '#options' => $options,
      '#default_value' => array_pop($default_options),
      
if ($modules_installed || $modules_uninstalled) {
        // Note that resetAll() does not reset the kernel module list so we         // have to do that manually.         $this->kernel->updateModules($module_handler_list$module_handler_list);
      }

      // Close any open database connections. This allows DB drivers that store       // static information to refresh it in the update runner.       // @todo https://drupal.org/i/3222121 consider doing this in       // \Drupal\Core\DrupalKernel::initializeContainer() for container       // rebuilds.       foreach (Database::getAllConnectionInfo() as $key => $info) {
        Database::closeConnection(NULL, $key);
      }

      // If we have successfully clicked 'Apply pending updates' then we need to       // clear the caches in the update test runner as this has occurred as part       // of the updates.       $this->resetAll();

      // The config schema can be incorrect while the update functions are being       // executed. But once the update has been completed, it needs to be valid       // again. Assert the schema of all configuration objects now.
Home | Imprint | This part of the site doesn't use cookies.