Problem/Motivation
Database drivers should be reachable even if no container is available.
This code in database caters for that
/**
* Returns the list provider for available database drivers.
*
* @return \Drupal\Core\Extension\DatabaseDriverList
* The list provider for available database drivers.
*/
public static function getDriverList(): DatabaseDriverList {
if (\Drupal::hasContainer() && \Drupal::hasService('extension.list.database_driver')) {
return \Drupal::service('extension.list.database_driver');
}
else {
return new DatabaseDriverList(DRUPAL_ROOT, 'database_driver', new NullBackend('database_driver'));
}
}
but the non-service alternative is failed later when DatabaseDriver::load()
tries to access the class_loader
service.
Steps to reproduce
Found this while trying to adjust Drush's interactive site:install command, that runs when no db-url option is passed in.