You are here

function db_installer_object in Drupal 10

Same name and namespace in other branches
  1. 8 core/includes/install.inc \db_installer_object()
  2. 7 includes/install.inc \db_installer_object()
  3. 9 core/includes/install.inc \db_installer_object()

Returns a database installer object.

Before calling this function it is important the database installer object is autoloadable. Database drivers provided by contributed modules are added to the autoloader in drupal_get_database_types() and Settings::initialize().

Parameters

$driver: The name of the driver.

string $namespace: (optional) The database driver namespace.

Return value

\Drupal\Core\Database\Install\Tasks A class defining the requirements and tasks for installing the database.

Deprecated

in drupal:10.0.0 and is removed from drupal:11.0.0. There is no replacement.

See also

https://www.drupal.org/node/3256641

drupal_get_database_types()

\Drupal\Core\Site\Settings::initialize()

1 call to db_installer_object()
InstallerObjectTest::testDbInstallerObject in core/tests/Drupal/Tests/Core/Database/InstallerObjectTest.php
@dataProvider providerDbInstallerObject

File

core/includes/install.inc, line 1191
API functions for installing modules and themes.

Code

function db_installer_object($driver, $namespace = NULL) {
  @trigger_error('db_installer_object() is deprecated in drupal:10.0.0 and is removed from drupal:11.0.0. There is no replacement. See https://www.drupal.org/node/3256641', E_USER_DEPRECATED);

  // We cannot use Database::getConnection->getDriverClass() here, because
  // the connection object is not yet functional.
  if ($namespace) {
    $task_class = $namespace . "\\Install\\Tasks";
    return new $task_class();
  }

  // Old Drupal 8 style contrib namespace.
  $task_class = "Drupal\\Driver\\Database\\{$driver}\\Install\\Tasks";
  if (class_exists($task_class)) {
    return new $task_class();
  }
  else {

    // Core provided driver.
    $task_class = "Drupal\\Core\\Database\\Driver\\{$driver}\\Install\\Tasks";
    return new $task_class();
  }
}