Создает и конфигурирует драйвер БД
@param array $connectionConfig конфигурация драйвера
@throws InvalidArgumentException если конфигурация не валидна
@return array [IConnection, IDialect]
500493
protected function configureConnection($connectionConfig)
    {
        $this->validateConnectionConfig($connectionConfig);

        $options = [];
        if (isset($connectionConfig['options'])) {
            $options = $connectionConfig['options'];
        }

        $options['driver'] = $connectionConfig['type'];

        $dialectClass = $this->dialectMap[$connectionConfig['type']];

        /** @var IDialect $dialect */
        $dialect = new $dialectClass;

        $options['platform'] = $dialect;

        $connection = DriverManager::getConnection($options);

        $dialect->initConnection($connection);

        return [
            $connection,
            $dialect
        ];
    }
781748
public function setConfiguration( models\Connection\Config $connectionConfig){
        $rest = $this->getService( self::API_CONNECTION_CONFIG);
        $rest->PUT( $connectionConfig);

        return $rest->getResult( models\Connection\Config::class);
    }
958000
protected function check_config ($config)
	{
		if ($config->is_empty()) {
			throw new \InvalidArgumentException("Given configuration is empty.");
		}

		if (empty($config->type) || !is_a_string($config->type)) {
			throw new \InvalidArgumentException("Given configuration contains no or a non-string database type.");
		}

		/* NOTE: Even though PDO definitely sports more than those three
		 * drivers, we have not tested any of those as of now. Especially not
		 * with Bacon as a whole. So I'd like to keep them "not supported" for
		 * now and add them later on if we, or anyone else ever need it.
		 */
		if (!V($this->supported_drivers)->includes($config->type)) {
			throw new \InvalidArgumentException("Given configuration contains an unsupported type: {$this->config->type}\nSupported types are: sqlite, mysql, pgsql");
		}

		if ('sqlite' == $config->type) {
			if (empty($config->name) || !is_a_string($config->name)) {
				throw new \InvalidArgumentException("Using SQLite but given configuration contains no or an invalid database name.");
			}

			/* NOTE: We may as well need to check the directory holding the
			 * database file according to this:
			 * http://stackoverflow.com/questions/61085/sqlite-php-read-only
			 */
			if (!\Sauce\Path::check($config->name, 'f', 'rw')) {
				throw new \InvalidArgumentException("Using SQLite but given database is not readable and writable: {$config->name}");
			}
		}

		if ('mysql' == $config->type || 'pgsql' == $config->type) {
			if (empty($config->host) || !is_a_string($config->host)) {
				throw new \InvalidArgumentException("Using MySQL or PostgreSQL but no or an invalid database host was given: {$config->host}");
			}

			if (empty($config->name) || !is_a_string($config->name)) {
				throw new \InvalidArgumentException("Using MySQL or PostgreSQL but no or an invalid database name was given.");
			}
		}

		if ('mysql' == $config->type && empty($config->encoding)) {
			$this->log->warning("Using MySQL but no encoding was given, defaulting to 'UTF8'. If you are using another encoding, please make sure to add it to your Config/Database.php.");

			$config->encoding = 'UTF8';
		}

		return $config;
	}
57095
protected function getConnectionDriver(array $settings = [])
    {
        $connection = Arr::get($settings, 'connection');
        $key        = 'database.connections.' . $connection;

        if (!$this->config->has($key)) {
            throw new InvalidArgumentException("Connection [{$connection}] has no configuration in [{$key}]");
        }

        return $this->config->get($key);
    }
294508
protected function _applyConfig($config)
    {
        if (is_string($config)) {
            $name = $config;
            $config = static::getConfig($name);
            if (empty($config)) {
                throw new InvalidArgumentException(sprintf('Unknown email configuration "%s".', $name));
            }
            unset($name);
        }

        $this->_profile = array_merge($this->_profile, $config);

        $simpleMethods = [
            'from', 'sender', 'to', 'replyTo', 'readReceipt', 'returnPath',
            'cc', 'bcc', 'messageId', 'domain', 'subject', 'attachments',
            'transport', 'emailFormat', 'emailPattern', 'charset', 'headerCharset'
        ];
        foreach ($simpleMethods as $method) {
            if (isset($config[$method])) {
                $this->{'set' . ucfirst($method)}($config[$method]);
            }
        }

        if (empty($this->headerCharset)) {
            $this->headerCharset = $this->charset;
        }
        if (isset($config['headers'])) {
            $this->setHeaders($config['headers']);
        }

        $viewBuilderMethods = [
            'template', 'layout', 'theme'
        ];
        foreach ($viewBuilderMethods as $method) {
            if (array_key_exists($method, $config)) {
                $this->viewBuilder()->{'set' . ucfirst($method)}($config[$method]);
            }
        }

        if (array_key_exists('helpers', $config)) {
            $this->viewBuilder()->setHelpers($config['helpers'], false);
        }
        if (array_key_exists('viewRender', $config)) {
            $this->viewBuilder()->setClassName($config['viewRender']);
        }
        if (array_key_exists('viewVars', $config)) {
            $this->set($config['viewVars']);
        }
    }
1231131
public static function createConnectionType(array $config)
    {
        if (!array_key_exists('nodeType', $config)){
            throw new \InvalidArgumentException('Connection config needs to have at least a node definition');
        }
        $nodeType = $config['nodeType'];
        $name = array_key_exists('name', $config) ? $config['name'] : $nodeType->name;
        $connectionFields = array_key_exists('connectionFields', $config) ? $config['connectionFields'] : [];
        $edgeType = array_key_exists('edgeType', $config) ? $config['edgeType'] : null;

        $connectionType = new ObjectType([
            'name' => $name . 'Connection',
            'description' => 'A connection to a list of items.',
            'fields' => function() use ($edgeType, $connectionFields, $config) {
                return array_merge([
                    'pageInfo' => [
                        'type' => Type::nonNull(self::pageInfoType()),
                        'description' => 'Information to aid in pagination.'
                    ],
                    'edges' => [
                        'type' => Type::listOf($edgeType ?: self::createEdgeType($config)),
                        'description' => 'Information to aid in pagination'
                    ]
                ], self::resolveMaybeThunk($connectionFields));
            }
        ]);

        return $connectionType;
    }
485980
public static function get($config = null) {
		if (!isset($config['driver'])) {
			throw new ConnectionException("Unknown driver");
		}
		if (!isset($config['host']) || !isset($config['port'])) {
			throw new ConnectionException("Host and Port is required");
		}
		$type = $config['driver'];
		$hash = md5($type . ':' . $config['host'] . ':' . $config['port']);
		if (!isset(self::$created_driver[$hash])) {
			if (isset(self::$driver[$type])) {
				$className = self::$driver[$type];
			} else {
				$className = __NAMESPACE__ . '\\Driver\\' . ucfirst($type);
			}
			self::$created_driver[$hash] = new $className($config);
		}
		return self::$created_driver[$hash];
	}
1166910
public function getConnectionConfig($name)
    {
        $name = $name ?: $this->default;

        if (!is_array($config = Arr::get($this->config, $name)) && !$config) {
            throw new InvalidArgumentException("Connection [$name] not configured.");
        }

        return $config;
    }
562804
public function connect(array $config, string $name = 'main'): Connection
    {
        if (isset($this->connections[$name])) {
            throw new InvalidArgumentException("Connection [$name] is already configured.");
        }

        $this->connections[$name] = new Connection($config);

        return $this->connections[$name];
    }
1194174
protected function getAuth(array $config)
	{
		if (isset($config['key']) && trim($config['key']) != '')
		{
			return array('key' => $config['key'], 'keyphrase' => $config['keyphrase']);
		}
		elseif (isset($config['keytext']) && trim($config['keytext']) != '')
		{
			return array('keytext' => $config['keytext']);
		}
		elseif (isset($config['password']))
		{
			return array('password' => $config['password']);
		}

		throw new \InvalidArgumentException('Password / key is required.');
	}
845668
public function configure($config = [])
    {
        return new static ([
            'driver'      => 'pdo_mysql',
            'host'        => array_get($config, 'host'),
            'dbname'      => array_get($config, 'database'),
            'user'        => array_get($config, 'username'),
            'password'    => array_get($config, 'password'),
            'charset'     => array_get($config, 'charset'),
            'port'        => array_get($config, 'port'),
            'unix_socket' => array_get($config, 'unix_socket'),
            'prefix'      => array_get($config, 'prefix'),
        ]);
    }
469315
public function setConfig($config)
    {
        if (!is_array($config) && !$config instanceof ArrayAccess) {
            throw new InvalidArgumentException('Config has to be array or ArrayAccess');
        }
        $this->config = $config;

        return $this;
    }
1061578
protected function getConnectionByName(array $connectionNames)
    {
        $connections = [];
        foreach ($connectionNames as $connectionName) {
            $uniqueChannelId = $this->getUniqueChannelId($this->getConnectionMap()[$connectionName]);
            $connections[$uniqueChannelId] = $this->getConnectionMap()[$connectionName];
        }

        return $connections;
    }
593700
public static function connect(ConnectionParameters $config){

		//Not static
		$con = new self();
		
		switch(\strtolower(\trim($config->getDriver()))){
			
			case 'sqlite':
				$con->Connection = new \PDO(
						\sprintf('sqlite:%s', $config->getHost()),
						$config->getUsername(),
						$config->getPassword(),
						$config->getOptions());
				break;
			
			default:
				$con->Connection = new \PDO(\sprintf(
						'%s:host=%s;charset=%s;dbname=%s',
						$config->getDriver() ? $config->getDriver() : '',
						$config->getHost() ? $config->getHost() : '',
						$config->getCharset() ? $config->getCharset() : '',
						$config->getDatabaseName() ? $config->getDatabaseName() : ''
					),
					$config->getUsername(),
					$config->getPassword(),
					$config->getOptions());
				break;
			
		}
		
		return $con;

	}
396784
public function setConnection($connectionConfig)
    {
        self::$config = static::parseUrl($connectionConfig);

        try {
            return  static::createConnection(self::$config);
        } catch (\PDOException $e) {
            throw new \Exception($e->getMessage());
        }
    }
1057035
private function mapLaravelToDoctrineConfig($config)
    {
        $default = $config['database.default'];
        $connection = $config["database.connections.{$default}"];
        return App::make(DriverMapper::class)->map($connection);
    }
42498
public function connection($config = null, $forceConnect = false)
    {

        if ($this->connection && !$forceConnect) {
            return $this->connection;
        }

        !isset($config) || $this->config($config);

        $ref = new \ReflectionClass($this->getHandler());

        try {
            /** @var \PDO $connection */
            $this->connection = $ref->newInstanceArgs([
                $this->getConnectionString(),
                $this->getUser(),
                $this->getPassword(),
                $this->getHandlerOptions()
            ]);
        } catch (\PDOException $e) {
            throw new DatabaseException($e->getMessage());
        }

        return $this->connection;
    }