function DatabaseDriverList::getFromDriverName

Returns the first available driver extension by the driver name.

Parameters

string $driverName: The database driver name.

Return value

\Drupal\Core\Extension\DatabaseDriver The driver extension.

Throws

\Drupal\Core\Extension\Exception\UnknownExtensionException When no matching driver extension can be found.

Deprecated

in drupal:10.2.0 and is removed from drupal:11.0.0. Use DatabaseDriverList::get() instead, passing a database driver namespace.

See also

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

1 call to DatabaseDriverList::getFromDriverName()
DatabaseDriverList::get in core/lib/Drupal/Core/Extension/DatabaseDriverList.php
Returns a single extension.

File

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

Class

DatabaseDriverList
Provides a list of available database drivers.

Namespace

Drupal\Core\Extension

Code

public function getFromDriverName(string $driverName) : DatabaseDriver {
    @trigger_error(__METHOD__ . '() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use DatabaseDriverList::get() instead, passing a database driver namespace. See https://www.drupal.org/node/3258175', E_USER_DEPRECATED);
    foreach ($this->getList() as $extensionName => $driver) {
        $namespaceParts = explode('\\', $extensionName);
        if (end($namespaceParts) === $driverName) {
            return parent::get($extensionName);
        }
    }
    throw new UnknownExtensionException("Could not find a database driver named '{$driverName}' in any module");
}

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