if (!
$module) { // Determine the connection class to use. Discover if the URL has a valid
// driver scheme for a Drupal 8 style custom driver.
// @todo Remove this in Drupal 10.
$connection_class = "Drupal\\Driver\\Database\\{
$driver}\\Connection";
} if (!
class_exists($connection_class)) { throw new \
InvalidArgumentException("Can not convert '
$url' to a database connection, class '
$connection_class' does not exist"
);
} $options =
$connection_class::
createConnectionOptionsFromUrl($url,
$root);
// If the driver is provided by a module add the necessary information to
// autoload the code.
// @see \Drupal\Core\Site\Settings::initialize()
if (isset($psr4_base_directory)) { $options['autoload'
] =
$psr4_base_directory;
} return $options;
}