You are here

public static function Connection::createUrlFromConnectionOptions in Drupal 10

File

core/modules/sqlite/src/Driver/Database/sqlite/Connection.php, line 467

Class

Connection
SQLite implementation of \Drupal\Core\Database\Connection.

Namespace

Drupal\sqlite\Driver\Database\sqlite

Code

public static function createUrlFromConnectionOptions(array $connection_options) {
  if (!isset($connection_options['driver'], $connection_options['database'])) {
    throw new \InvalidArgumentException("As a minimum, the connection options array must contain at least the 'driver' and 'database' keys");
  }
  $db_url = 'sqlite://localhost/' . $connection_options['database'] . '?module=sqlite';
  if (isset($connection_options['prefix']) && $connection_options['prefix'] !== '') {
    $db_url .= '#' . $connection_options['prefix'];
  }
  return $db_url;
}