Skip to content
Permalink
Browse files

3978 db dump exception (#3979)

* Add new arguments key and target. Make it possible use not only default target for db connections

* Throw an exception if db is not found
  • Loading branch information...
LOBsTerr committed Apr 10, 2019
1 parent ad79269 commit 6d6ac03b0627b60816e4662e25839a319d20b96b
Showing with 12 additions and 22 deletions.
  1. +12 −22 src/Command/Shared/ConnectTrait.php
@@ -16,31 +16,21 @@ trait ConnectTrait
public function resolveConnection($key = 'default', $target = 'default')
{
$connectionInfo = Database::getConnectionInfo($key);
if (!$connectionInfo || !isset($connectionInfo[$target])) {
$this->getIo()->error(
sprintf(
$this->trans('commands.database.connect.messages.database-not-found'),
$key,
$target
)
);
return null;
if (empty($connectionInfo[$target])) {
throw new \Exception(sprintf(
$this->trans('commands.database.connect.messages.database-not-found'),
$key,
$target
));
}
$databaseConnection = $connectionInfo[$target];
if (!in_array($databaseConnection['driver'], $this->supportedDrivers)) {
$this->getIo()->error(
sprintf(
$this->trans('commands.database.connect.messages.database-not-supported'),
$databaseConnection['driver']
)
);
return null;
else if (!in_array($connectionInfo[$target]['driver'], $this->supportedDrivers)) {
throw new \Exception(sprintf(
$this->trans('commands.database.connect.messages.database-not-supported'),
$connectionInfo[$target]['driver']
));
}
return $databaseConnection;
return $connectionInfo[$target];
}
public function getRedBeanConnection($database = 'default')

0 comments on commit 6d6ac03

Please sign in to comment.
You can’t perform that action at this time.