DbServerHandlerFactory.php in DB Maintenance 2.0.x
Same filename and directory in other branches
DbServerHandlerFactory class.
Namespace
Drupal\db_maintenance\Module\Db\DbServerFile
src/Module/Db/DbServer/DbServerHandlerFactory.phpView source
<?php
/**
* @file
* DbServerHandlerFactory class.
*/
namespace Drupal\db_maintenance\Module\Db\DbServer;
use Drupal\db_maintenance\Module\Db\DbServer\MySql\MySqlHandler;
use Drupal\db_maintenance\Module\Db\DbServer\PgSql\PgSqlHandler;
/**
* DbServerHandlerFactory class.
*/
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;
}
}
Classes
Name | Description |
---|---|
DbServerHandlerFactory | DbServerHandlerFactory class. |