Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 25 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| tao_install_utils_DbalConfigCreator | |
0.00% |
0 / 25 |
|
0.00% |
0 / 1 |
20 | |
0.00% |
0 / 1 |
| createDbalConfig | |
0.00% |
0 / 25 |
|
0.00% |
0 / 1 |
20 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License |
| 6 | * as published by the Free Software Foundation; under version 2 |
| 7 | * of the License (non-upgradable). |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 | * |
| 18 | * Copyright (c) 2013-2021 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT); |
| 19 | * |
| 20 | * @author Lionel Lecaque <lionel@taotesting.com> |
| 21 | * @license GPLv2 |
| 22 | */ |
| 23 | |
| 24 | declare(strict_types=1); |
| 25 | |
| 26 | class tao_install_utils_DbalConfigCreator |
| 27 | { |
| 28 | public function createDbalConfig($installData) |
| 29 | { |
| 30 | if ($installData['db_driver'] == 'pdo_oci') { |
| 31 | $installData['db_name'] = $installData['db_host']; |
| 32 | $installData['db_host'] = ''; |
| 33 | } |
| 34 | |
| 35 | $dbConnectionParams = [ |
| 36 | 'driver' => $installData['db_driver'], |
| 37 | 'driverClass' => $installData['db_driverClass'] ?? null, |
| 38 | 'instance' => $installData['db_instance'] ?? null, |
| 39 | 'host' => $installData['db_host'], |
| 40 | 'dbname' => $installData['db_name'], |
| 41 | 'user' => $installData['db_user'], |
| 42 | 'password' => $installData['db_pass'], |
| 43 | 'driverOptions' => $installData['db_driverOptions'] ?? [], |
| 44 | ]; |
| 45 | |
| 46 | $hostParts = explode(':', $installData['db_host']); |
| 47 | if (count($hostParts) == 2) { |
| 48 | $dbConnectionParams['host'] = $hostParts[0]; |
| 49 | $dbConnectionParams['port'] = $hostParts[1]; |
| 50 | } |
| 51 | |
| 52 | if ($installData['db_driver'] == 'pdo_oci') { |
| 53 | $dbConnectionParams['wrapperClass'] = 'Doctrine\DBAL\Portability\Connection'; |
| 54 | $dbConnectionParams['portability'] = \Doctrine\DBAL\Portability\Connection::PORTABILITY_ALL; |
| 55 | $dbConnectionParams['fetch_case'] = PDO::CASE_LOWER; |
| 56 | } |
| 57 | |
| 58 | return [ |
| 59 | 'driver' => 'dbal', |
| 60 | 'connection' => $dbConnectionParams, |
| 61 | ]; |
| 62 | } |
| 63 | } |