This commit is contained in:
2020-09-02 15:33:52 +08:00
parent f8a9de8181
commit a458400bdd
+16 -9
View File
@@ -26,12 +26,12 @@ class DatabasesProviders extends Component
*/ */
public function get($name) public function get($name)
{ {
$name = 'databases.' . $name;
$config = Config::get('databases.' . $name, true);
$application = Snowflake::get(); $application = Snowflake::get();
if (!$application->has($name)) { if ($application->has('databases.' . $name)) {
$generate = [ return $application->get('databases.' . $name);
}
$config = $this->getConfig($name);
return $application->set('databases.' . $name, [
'class' => Connection::class, 'class' => Connection::class,
'id' => 'db', 'id' => 'db',
'cds' => $config['cds'], 'cds' => $config['cds'],
@@ -40,11 +40,18 @@ class DatabasesProviders extends Component
'tablePrefix' => $config['tablePrefix'], 'tablePrefix' => $config['tablePrefix'],
'maxNumber' => 100, 'maxNumber' => 100,
'slaveConfig' => $config['slaveConfig'] 'slaveConfig' => $config['slaveConfig']
]; ]);
return $application->set($name, $generate);
} else {
return $application->get($name);
} }
/**
* @param $name
* @return array|mixed|null
* @throws ConfigException
*/
public function getConfig($name)
{
return Config::get('databases.' . $name, true);
} }