Skip to content

Commit

Permalink
Add support for DSN v2 (#72)
Browse files Browse the repository at this point in the history
* Add support for DSN v2

* Remove beta flag

* cs
  • Loading branch information
Nyholm authored Oct 16, 2020
1 parent 369b0c9 commit 50d272f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions Factory/ConfigFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace BM\BackupManagerBundle\Factory;

use BackupManager\Config\Config;
use Nyholm\DSN;
use Nyholm\Dsn\DsnParser;

/**
* A factory class to resolve DSN
Expand All @@ -21,13 +21,13 @@ public static function createConfig(array $config)
{
foreach ($config as $key => $databaseConfig) {
if (isset($databaseConfig['dsn'])) {
$dsn = new DSN($databaseConfig['dsn']);
$config[$key]['type'] = $dsn->getProtocol();
$config[$key]['host'] = $dsn->getFirstHost();
$config[$key]['port'] = $dsn->getFirstPort();
$config[$key]['user'] = $dsn->getUsername();
$dsn = DsnParser::parseUrl($databaseConfig['dsn']);
$config[$key]['type'] = $dsn->getScheme();
$config[$key]['host'] = $dsn->getHost();
$config[$key]['port'] = $dsn->getPort();
$config[$key]['user'] = $dsn->getUser();
$config[$key]['pass'] = $dsn->getPassword();
$config[$key]['database'] = $dsn->getDatabase();
$config[$key]['database'] = $dsn->getPath();
unset($config[$key]['dsn']);
}
}
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"require": {
"php": "^7.3",
"backup-manager/backup-manager": "^3.0",
"nyholm/dsn": "^1.0",
"nyholm/dsn": "^2.0",
"symfony/config": "^3.4 || ^4.4 || ^5.0",
"symfony/console": "^3.4 || ^4.4 || ^5.0",
"symfony/dependency-injection": "^3.4 || ^4.4 || ^5.0",
Expand Down

0 comments on commit 50d272f

Please sign in to comment.