function DatabaseDriverList::doList

Same name in other branches
  1. 11.x core/lib/Drupal/Core/Extension/DatabaseDriverList.php \Drupal\Core\Extension\DatabaseDriverList::doList()

Overrides ExtensionList::doList

File

core/lib/Drupal/Core/Extension/DatabaseDriverList.php, line 80

Class

DatabaseDriverList
Provides a list of available database drivers.

Namespace

Drupal\Core\Extension

Code

protected function doList() : array {
    // Determine the modules that contain at least one installable database
    // driver.
    $discoveredModules = $this->doScanExtensions();
    $drivers = [];
    foreach ($discoveredModules as $module) {
        $moduleDriverDirectory = $this->root . DIRECTORY_SEPARATOR . $module->getPath() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'Driver' . DIRECTORY_SEPARATOR . 'Database';
        if (is_dir($moduleDriverDirectory)) {
            // Use directory iterator to avoid services.
            $directoryIterator = new \DirectoryIterator($moduleDriverDirectory);
            foreach ($directoryIterator as $fileInfo) {
                if ($fileInfo->isDir() && !$fileInfo->isDot() && file_exists($moduleDriverDirectory . DIRECTORY_SEPARATOR . $fileInfo->getFilename() . DIRECTORY_SEPARATOR . 'Install' . DIRECTORY_SEPARATOR . 'Tasks.php')) {
                    $databaseDriver = new DatabaseDriver($this->root, $module, $fileInfo->getFilename(), $discoveredModules);
                    $drivers[$databaseDriver->getName()] = $databaseDriver;
                }
            }
        }
    }
    return $drivers;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.