* @license GPLv2 */ /** * The class is a helper to generate the persistence config * based on command line parameters or web installer parameters */ class tao_install_utils_DbalConfigCreator { public function createDbalConfig($installData) { if ($installData['db_driver'] == 'pdo_oci') { $installData['db_name'] = $installData['db_host']; $installData['db_host'] = ''; } $dbConnectionParams = [ 'driver' => $installData['db_driver'], 'driverClass' => $installData['db_driverClass'] ?? null, 'instance' => $installData['db_instance'] ?? null, 'host' => $installData['db_host'], 'dbname' => $installData['db_name'], 'user' => $installData['db_user'], 'password' => $installData['db_pass'], 'driverOptions' => $installData['db_driverOptions'] ?? [], ]; $hostParts = explode(':', $installData['db_host']); if (count($hostParts) == 2) { $dbConnectionParams['host'] = $hostParts[0]; $dbConnectionParams['port'] = $hostParts[1]; } if ($installData['db_driver'] == 'pdo_mysql') { $dbConnectionParams['dbname'] = ''; } if ($installData['db_driver'] == 'pdo_oci') { $dbConnectionParams['wrapperClass'] = 'Doctrine\DBAL\Portability\Connection'; $dbConnectionParams['portability'] = \Doctrine\DBAL\Portability\Connection::PORTABILITY_ALL; $dbConnectionParams['fetch_case'] = PDO::CASE_LOWER; } // reset db name for mysql if ($installData['db_driver'] == 'pdo_mysql') { $dbConnectionParams['dbname'] = $installData['db_name']; } return [ 'driver' => 'dbal', 'connection' => $dbConnectionParams, ]; } }