public function prepareConfig($dbConfig = [])
    {
        if ($this->config('connection')) {
            return true;
        }

        if (is_readable(ROOT . '/config/settings.php.tmp')) {
            $dbConfig = include ROOT . '/config/settings.php.tmp';
            if (empty($dbConfig['Datasources']['default'])) {
                $this->error(__d('installer', 'Invalid database information in file "{0}"', ROOT . '/config/settings.php.tmp'));

                return false;
            }
            $dbConfig = $dbConfig['Datasources']['default'];
        } else {
            if (empty($dbConfig['driver'])) {
                $dbConfig['driver'] = '__INVALID__';
            }
            if (strpos($dbConfig['driver'], "\\") === false) {
                $dbConfig['driver'] = "Cake\\Database\\Driver\\{$dbConfig['driver']}";
            }
        }

        list(, $driverClass) = namespaceSplit($dbConfig['driver']);
        if (!in_array($driverClass, ['Mysql', 'Postgres', 'Sqlite', 'Sqlserver'])) {
            $this->error(__d('installer', 'Invalid database type ({0}).', $driverClass));

            return false;
        }

        $this->config('connection', Hash::merge($this->_defaultConnection, $dbConfig));

        return true;
    }