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;
    }
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;
    }
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 ; }
Prepares database configuration attributes.

If the file "ROOT/config/settings.php.tmp" exists, and has declared a
connection named "default" it will be used.

@param array $dbConfig Database connection info coming from POST
@return bool True on success, false otherwise
Prepares database configuration attributes .