drupal_get_database_types example


  protected function getDatabaseTypes() {
    if (isset($this->originalContainer) && $this->originalContainer) {
      \Drupal::setContainer($this->originalContainer);
    }
    $database_types = drupal_get_database_types();
    if (isset($this->originalContainer) && $this->originalContainer) {
      \Drupal::unsetContainer();
    }
    return $database_types;
  }

}

  protected function getCredentials() {
    $connection_options = $this->sourceDatabase->getConnectionOptions();
    $version = $this->getLegacyDrupalVersion($this->sourceDatabase);
    $driver = $connection_options['driver'];

    // Use the driver connection form to get the correct options out of the     // database settings. This supports all of the databases we test against.     $drivers = drupal_get_database_types();
    $form = $drivers[$driver]->getFormOptions($connection_options);
    $connection_options = array_intersect_key($connection_options$form + $form['advanced_options']);
    // Remove isolation_level since that option is not configurable in the UI.     unset($connection_options['isolation_level']);
    $edit = [
      $driver => $connection_options,
      'source_private_file_path' => $this->getSourceBasePath(),
      'version' => $version,
    ];
    if ($version == 6) {
      $edit['d6_source_base_path'] = $this->getSourceBasePath();
    }
->execute();
    $this->sourceDatabase->update('variable')
      ->fields(['value' => serialize($file_temporary_path)])
      ->condition('name', 'file_temporary_path')
      ->execute();

    $connection_options = $this->sourceDatabase->getConnectionOptions();
    $driver = $connection_options['driver'];

    // Use the driver connection form to get the correct options out of the     // database settings. This supports all of the databases we test against.     $drivers = drupal_get_database_types();
    $form = $drivers[$driver]->getFormOptions($connection_options);
    $connection_options = array_intersect_key($connection_options$form + $form['advanced_options']);
    // Remove isolation_level since that option is not configurable in the UI.     unset($connection_options['isolation_level']);
    $edit = [
      $driver => $connection_options,
      'version' => '7',
    ];
    if (count($drivers) !== 1) {
      $edit['driver'] = $driver;
    }
    


  /** * Returns all supported database driver installer objects. * * @return \Drupal\Core\Database\Install\Tasks[] * An array of available database driver installer objects. */
  protected function getDatabaseTypes() {
    // Make sure the install API is available.     include_once DRUPAL_ROOT . '/core/includes/install.inc';
    return drupal_get_database_types();
  }

  /** * Gets and stores information for this migration in temporary store. * * Gets all the migrations, converts each to an array and stores it in the * form state. The source base path for public and private files is also * put into form state. * * @param \Drupal\Core\Database\Connection $connection * The database connection used. * @param string $version * The Drupal version. * @param array $database * Database array representing the source Drupal database. * @param \Drupal\Core\Form\FormStateInterface $form_state * The current state of the form. * * @throws \Drupal\Core\TempStore\TempStoreException * Thrown when a lock for the backend storage could not be acquired. */
/** * {@inheritdoc} */
  public function buildForm(array $form, FormStateInterface $form_state) {
    // Make sure the install API is available.     include_once DRUPAL_ROOT . '/core/includes/install.inc';
    $settings_file = './' . $this->sitePath . '/settings.php';

    $form['#title'] = $this->t('Database configuration');

    $drivers = drupal_get_database_types();
    $drivers_keys = array_keys($drivers);

    // Unless there is input for this form (for a non-interactive installation,     // input originates from the $settings array passed into install_drupal()),     // check whether database connection settings have been prepared in     // settings.php already.     // Note: The installer even executes this form if there is a valid database     // connection already, since the submit handler of this form is responsible     // for writing all $settings to settings.php (not limited to $databases).     $input = &$form_state->getUserInput();
    if (!isset($input['driver']) && $database = Database::getConnectionInfo()) {
      
Home | Imprint | This part of the site doesn't use cookies.