This is a fallback for get the connection instead of the old database.

@param array $config The configuration.

@return void

@deprecated This method is deprecated sinde 2.1 and where removed in 3.0. The old database never used in future.
17767
private function fallbackFromDatabaseToConnection(array &$config)
    {
        if (isset($config['database'])) {
            // @codingStandardsIgnoreStart
            @\trigger_error(
                'Config key database is deprecated use instead connection. Fallback will be dropped.',
                E_USER_DEPRECATED
            );
            // @codingStandardsIgnoreEnd

            if (!isset($config['connection'])) {
                $config['connection'] = $config['database'];
            }

            unset($config['database']);
        }

        if (isset($config['connection']) && $config['connection'] instanceof Database) {
            // @codingStandardsIgnoreStart
            @\trigger_error(
                '"' . __METHOD__ . '" now accepts doctrine instances - ' .
                'passing Contao database instances is deprecated.',
                E_USER_DEPRECATED
            );
            // @codingStandardsIgnoreEnd
            $reflection = new \ReflectionProperty(Database::class, 'resConnection');
            $reflection->setAccessible(true);

            $config['connection'] = $reflection->getValue($config['connection']);
        }
    }
448342
protected function _connection(array $config)
    {
        $redis = new \Redis;
        $host = empty($config['host']) ? self::DEFAULT_HOST : $config['host'];
        $port = empty($config['port']) ? self::DEFAULT_PORT : $config['port'];
        $timeout = empty($config['timeout']) ? self::DEFAULT_TIMEOUT : $config['timeout'];
        $connect = empty($config['persistent']) ? 'connect' : 'pconnect';
        $redis->$connect($host, $port, $timeout);
        return $redis;
    }
187027
public function init(array $config = [])
    {
        if (!extension_loaded('redis')) {
            return false;
        }

        if (!empty($config['host'])) {
            $config['server'] = $config['host'];
        }

        parent::init($config);

        return $this->_connect();
    }
50115
public function loadConfig(array $config)
    {
        $this->devServerEnabled = $config['dev_server_enable'];
        $this->devServerHost = $config['dev_server_host'];
        $this->devServerPort = $config['dev_server_port'];
    }
1042289
protected function ldapConnect(array $config)
    {
        // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
        $connection = @ldap_connect($config['host'], $config['port']);
        if (!is_resource($connection)) {
            $this->abort("Unable to connecto LDAP at [" . $config['host'] . ":" . $config['port'] . "]");
        }

        // set LDAP options
        ldap_set_option($connection, LDAP_OPT_PROTOCOL_VERSION, (int)$config['version']);
        ldap_set_option($connection, LDAP_OPT_REFERRALS, 0);
        ldap_set_option($connection, LDAP_OPT_NETWORK_TIMEOUT, 5);

        // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
        $bind = @ldap_bind($connection, $config['domain'] . '\\' . $config['username'], $config['password']);
        if ($bind === false) {
            $this->abort('Cannot bind with user: ' . $config['username'] . '.');
        }

        return $connection;
    }
1059108
public function initialize(array $config) {
		$this->setDisplayField('type');
		$this->addBehavior('Timestamp', ['modified' => false]);
		if (static::isSearchEnabled()) {
			$this->addBehavior('Search.Search');
		}
		$this->ensureTables(['DatabaseLog.DatabaseLogs']);

		$callback = Configure::read('DatabaseLog.monitorCallback');
		if (!$callback) {
			return;
		}
		$this->getEventManager()->on('DatabaseLog.alert', $callback);
	}
722727
protected function platformConnectHandler(Config $config)
    {
        $this->database = $config->database;

        if ($config->readOnly === true) {
            $this->handle = new \Sqlite3($config->database, SQLITE3_OPEN_READONLY);
        } else {
            $this->handle = new \Sqlite3($config->database, SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE);
        }

        // Enable throwing exceptions
        $this->handle->enableExceptions(true);

        // Set busy timeout
        if ($config->offsetExists('busyTimeout')) {
            if ($config->busyTimeout != 0) {
                $this->handle->busyTimeout($config->busyTimeout);
            }
        }
    }
876534
public function setHandler(array $config)
    {
        $connect = $config['connect'] ?? [];

        switch (strtolower($config['handler'])) {
            case 'redis':
                $class = Handler\Redis::class;
                $conn = Redis::client($connect);
                break;

            case 'simple':
            case 'simplecache':
                $class = Handler\SimpleCache::class;
                $conn = Cache::simple($connect);
                break;

            case 'cache':
                $class = Handler\Cache::class;
                $conn = Cache::pool($connect);
                break;

            case 'db':
                $class = Handler\Database::class;
                $conn = Database::pdo($connect);
                break;

            default:
                return;
        }

        $settings = $config['settings'] ?? [];
        if (!isset($settings['lifetime']) && isset($this->cookieParams['lifetime'])) {
            $settings['lifetime'] = $this->cookieParams['lifetime'];
        }

        $this->handler = new $class($conn, $settings);
    }
1136813
public function connect(array $config)
    {
        $dsn = "pgsql:host={$config['host']};dbname={$config['database']}";

        if (isset($config['port'])) {
            $dsn .= ";port={$config['port']}";
        }

        $connection = new \Pimf\Database($dsn, $config['username'], $config['password'], $this->options($config));

        // set to UTF-8 which should be fine for most scenarios.
        if (isset($config['charset'])) {
            $connection->prepare("SET NAMES '{$config['charset']}'")->execute();
        }

        // If a schema has been specified
        if (isset($config['schema'])) {
            $connection->prepare("SET search_path TO '{$config['schema']}'")->execute();
        }

        return $connection;
    }
680510
protected function createSingleConnection(array $config)
    {
        $pdo = $this->createPdoResolver($config);

        return $this->createConnection(
            $config['driver'], $pdo, $config['database'], $config['prefix'], $config
        );
    }
675411
public function connect(array $config)
    {
        return new DatabaseQueue(
            $this->connections->connection($config['connection'] ?? null),
            $config['table'],
            $config['queue'],
            $config['retry_after'] ?? 60
        );
    }
421030
public function connect(array $config){

		// Defaults
		$defaults = array(
			'resource' => null,
			'charset' => 'utf8',
			'username' => ini_get('mysqli.default_user'),
			'password' => ini_get('mysqli.default_pw'),
			'database' => '',
			'socket' => ini_get('mysqli.default_socket'),
			'port' => ini_get('mysqli.default_port'),
			'host' => ini_get('mysqli.default_host'),
			'persistent' => false,
			'unbuffered' => false
		);

		$config += $defaults;

		// Connect
		if($config['resource'] instanceof mysqli)
			$this->resource = $config['resource'];
		else
			$this->resource = new mysqli($config['host'], $config['username'], $config['password'], $config['database'], $config['port'], $config['socket']);

		if($this->resource->connect_errno)
			throw new DriverException($this->resource->connect_error, $this->resource->connect_errno);

		// Set charset
		if($this->resource instanceof mysqli){
			$ok = @$this->resource->set_charset($config['charset']);
			if(!$ok)
				$this->runQuery("SET NAMES " . $config['charset']);
		}

		$this->unbuffered = $config['unbuffered'];
	}
1234267
protected function getConnections(array $config)
    {
        if (!isset($config['connections'])) {
            throw new \RuntimeException('Configuration must contain a "connections" key');
        }

        if (!is_array($config['connections']) || !$config['connections']) {
            throw new \RuntimeException('Configuration "connections" key must reference a non-empty array');
        }

        $connections = array_filter(
            $config['connections'],
            function ($connection) {
                return $connection instanceof ConnectionInterface;
            }
        );
        if (count($connections) != count($config['connections'])) {
            throw new \RuntimeException(
                'All configuration "connections" array values must implement \Phergie\Irc\ConnectionInterface'
            );
        }

        return $connections;
    }
10065
public function connect(array $config)
    {
        /** @var CouchbaseConnection $connection */
        $connection = $this->connectionResolver->connection($config['driver']);

        return new CouchbaseQueue(
            $connection,
            $config['bucket'],
            $config['queue'],
            Arr::get($config, 'retry_after', 60)
        );
    }
432055
protected function _ldapConnect(array $config)
    {
        $result = false;

        // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
        $connection = @ldap_connect($config['host'], $config['port']);
        if (!is_resource($connection)) {
            Log::critical("Unable to connecto LDAP at [" . $config['host'] . ":" . $config['port'] . "]");

            return $result;
        }

        // set LDAP options
        ldap_set_option($connection, LDAP_OPT_PROTOCOL_VERSION, (int)$config['version']);
        ldap_set_option($connection, LDAP_OPT_REFERRALS, 0);
        ldap_set_option($connection, LDAP_OPT_NETWORK_TIMEOUT, 5);

        // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
        $bind = @ldap_bind($connection, $config['domain'] . '\\' . $config['username'], $config['password']);
        if ($bind === false) {
            Log::critical('Cannot bind with user: ' . $config['username']);

            return $result;
        }

        return $connection;
    }
1247607
public function connect(array $config)
    {
        return new DatabaseQueue(
            $this->connections->connection(array_get($config, 'connection')),
            array_get($config, 'table', 'queues'),
            array_get($config, 'queue', null),
            array_get($config, 'expire', 60),
            array_get($config, 'lock_type', 60)
        );
    }
1235928
public function initialize(array $config)
    {
        $controller = $this->_registry->getController();
        $this->setEventManager($controller->getEventManager());
        $this->response =& $controller->response;
        $this->session = $controller->getRequest()->getSession();

        if ($this->getConfig('ajaxLogin')) {
            deprecationWarning(
                'The `ajaxLogin` option is deprecated. Your client-side ' .
                'code should instead check for 403 status code and show ' .
                'appropriate login form.'
            );
        }
    }