protected function parseConnections($options, $defaultHost, $defaultPort) { if (isset($options['host']) || isset($options['port'])) { $options['connections'][] = $options; } /** @var Url[] $toParse */ $toParse = []; if (isset($options['connections'])) { foreach ((array) $options['connections'] as $alias => $conn) { if (is_string($conn)) { $conn = ['host' => $conn]; } $scheme = isset($conn['scheme']) ? $conn['scheme'] : 'tcp'; $host = isset($conn['host']) ? $conn['host'] : $defaultHost; $url = new Url($scheme, $host); $url->setPort(isset($conn['port']) ? $conn['port'] : $defaultPort); if (isset($conn['path'])) { $url->setPath($conn['path']); } if (isset($conn['password'])) { $url->setPassword($conn['password']); } $url->getQuery()->replace($conn); $toParse[] = $url; } } elseif (isset($options['save_path'])) { foreach (explode(',', $options['save_path']) as $conn) { $toParse[] = Url::fromString($conn); } } $connections = []; foreach ($toParse as $url) { $connections[] = ['scheme' => $url->getScheme(), 'host' => $url->getHost(), 'port' => $url->getPort(), 'path' => $url->getPath(), 'alias' => $url->getQuery()->get('alias'), 'prefix' => $url->getQuery()->get('prefix'), 'password' => $url->getPassword(), 'database' => $url->getQuery()->get('database'), 'persistent' => $url->getQuery()->get('persistent'), 'weight' => $url->getQuery()->get('weight'), 'timeout' => $url->getQuery()->get('timeout')]; } return $connections; }
/** * {@inheritdoc } */ public function getSchemeAndHost() { return sprintf('%s://%s', $this->baseUrl->getScheme(), $this->baseUrl->getHost()); }