You are here

final public static function Database::parseConnectionInfo in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Database/Database.php \Drupal\Core\Database\Database::parseConnectionInfo()

Process the configuration file for database information.

Parameters

array $info: The database connection information, as defined in settings.php. The structure of this array depends on the database driver it is connecting to.

1 call to Database::parseConnectionInfo()
Database::addConnectionInfo in core/lib/Drupal/Core/Database/Database.php
Adds database connection information for a given key/target.

File

core/lib/Drupal/Core/Database/Database.php, line 212
Contains \Drupal\Core\Database\Database.

Class

Database
Primary front-controller for the database system.

Namespace

Drupal\Core\Database

Code

public static final function parseConnectionInfo(array $info) {

  // If there is no "driver" property, then we assume it's an array of
  // possible connections for this target. Pick one at random. That allows
  // us to have, for example, multiple replica servers.
  if (empty($info['driver'])) {
    $info = $info[mt_rand(0, count($info) - 1)];
  }

  // Parse the prefix information.
  if (!isset($info['prefix'])) {

    // Default to an empty prefix.
    $info['prefix'] = array(
      'default' => '',
    );
  }
  elseif (!is_array($info['prefix'])) {

    // Transform the flat form into an array form.
    $info['prefix'] = array(
      'default' => $info['prefix'],
    );
  }
  return $info;
}