You are here

public static function DbServerHandlerFactory::getDbServerHandler in DB Maintenance 8

Same name and namespace in other branches
  1. 7.2 src/Module/Db/DbServer/DbServerHandlerFactory.php \Drupal\db_maintenance\Module\Db\DbServer\DbServerHandlerFactory::getDbServerHandler()
  2. 2.0.x src/Module/Db/DbServer/DbServerHandlerFactory.php \Drupal\db_maintenance\Module\Db\DbServer\DbServerHandlerFactory::getDbServerHandler()

Returns proper DbServerHandler.

2 calls to DbServerHandlerFactory::getDbServerHandler()
DbHandler::listTables in src/Module/Db/DbHandler.php
Gets a list of all the tables in a database.
DbHandler::optimizeTables in src/Module/Db/DbHandler.php
Performs the maintenance.

File

src/Module/Db/DbServer/DbServerHandlerFactory.php, line 22
DbServerHandlerFactory class.

Class

DbServerHandlerFactory
DbServerHandlerFactory class.

Namespace

Drupal\db_maintenance\Module\Db\DbServer

Code

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);
}