Skip to content
This repository was archived by the owner on May 11, 2021. It is now read-only.

Commit

Permalink
Fix version for the next release (#298)
Browse files Browse the repository at this point in the history
* Fix next ver

* small refactor
  • Loading branch information
mvorisek authored Apr 19, 2021
1 parent f58610c commit 30d9f16
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"require-release": {
"php": ">=7.3.0",
"ext-pdo": "*",
"atk4/core": "~2.4.0",
"atk4/core": "~2.5.0",
"doctrine/dbal": "^2.10 || ^3.0"
},
"require-dev": {
Expand Down
23 changes: 8 additions & 15 deletions src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,30 +127,23 @@ public static function connect($dsn, $user = null, $password = null, $args = [])
{
// If it's already PDO or DbalConnection object, then we simply use it
if ($dsn instanceof \PDO) {
$connectionClass = self::resolveConnectionClass(
$dsn->getAttribute(\PDO::ATTR_DRIVER_NAME)
);

return new $connectionClass(array_merge([
'connection' => $connectionClass::connectDbalConnection(['pdo' => $dsn]),
], $args));
$connectionClass = self::resolveConnectionClass($dsn->getAttribute(\PDO::ATTR_DRIVER_NAME));
$connectionArg = $connectionClass::connectDbalConnection(['pdo' => $dsn]);
} elseif ($dsn instanceof DbalConnection) {
/** @var \PDO */
$pdo = self::isComposerDbal2x()
? $dsn->getWrappedConnection()
: $dsn->getWrappedConnection()->getWrappedConnection(); // @phpstan-ignore-line
$connectionClass = self::resolveConnectionClass($pdo->getAttribute(\PDO::ATTR_DRIVER_NAME));

return new $connectionClass(array_merge([
'connection' => $dsn,
], $args));
$connectionArg = $dsn;
} else {
$dsn = static::normalizeDsn($dsn, $user, $password);
$connectionClass = self::resolveConnectionClass($dsn['driverSchema']);
$connectionArg = $connectionClass::connectDbalConnection($dsn);
}

$dsn = static::normalizeDsn($dsn, $user, $password);
$connectionClass = self::resolveConnectionClass($dsn['driverSchema']);

return new $connectionClass(array_merge([
'connection' => $connectionClass::connectDbalConnection($dsn),
'connection' => $connectionArg,
], $args));
}

Expand Down

0 comments on commit 30d9f16

Please sign in to comment.