class DbServerHandlerFactory in DB Maintenance 8
Same name and namespace in other branches
- 7.2 src/Module/Db/DbServer/DbServerHandlerFactory.php \Drupal\db_maintenance\Module\Db\DbServer\DbServerHandlerFactory
- 2.0.x src/Module/Db/DbServer/DbServerHandlerFactory.php \Drupal\db_maintenance\Module\Db\DbServer\DbServerHandlerFactory
DbServerHandlerFactory class.
Hierarchy
- class \Drupal\db_maintenance\Module\Db\DbServer\DbServerHandlerFactory
Expanded class hierarchy of DbServerHandlerFactory
1 file declares its use of DbServerHandlerFactory
- DbHandler.php in src/
Module/ Db/ DbHandler.php - DbHandler class.
File
- src/
Module/ Db/ DbServer/ DbServerHandlerFactory.php, line 17 - DbServerHandlerFactory class.
Namespace
Drupal\db_maintenance\Module\Db\DbServerView source
class DbServerHandlerFactory {
/**
* Returns proper DbServerHandler.
*/
public static function getDbServerHandler() {
if (\Drupal::database()
->driver() == 'mysql') {
$handler = new MySqlHandler();
}
elseif (\Drupal::database()
->driver() == 'pgsql') {
$handler = new PgSqlHandler();
}
else {
throw new \Exception(t('Unsupported DB server type.'));
}
return self::cast($handler);
}
/**
* Returns typed $handler as DbServerHandlerInterface.
*/
public static function cast(DbServerHandlerInterface &$object = NULL) {
return $object;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DbServerHandlerFactory:: |
public static | function | Returns typed $handler as DbServerHandlerInterface. | |
DbServerHandlerFactory:: |
public static | function | Returns proper DbServerHandler. |