/** * Retrieve connection by $connectionName * * @param string $connectionName * @return \Magento\Framework\DB\Adapter\AdapterInterface * @throws \DomainException */ public function getConnectionByName($connectionName) { if (isset($this->connections[$connectionName])) { return $this->connections[$connectionName]; } $connectionConfig = $this->deploymentConfig->get(ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTIONS . '/' . $connectionName); if ($connectionConfig) { $connection = $this->connectionFactory->create($connectionConfig); } else { throw new \DomainException('Connection "' . $connectionName . '" is not defined'); } $this->connections[$connectionName] = $connection; return $connection; }