public function updateConnector($id, array $connector, $regenerateType = false)
 {
     $this->assertConnector($connector);
     if (!$this->dbalConnections->containsKey($connector['dbal_connection'])) {
         throw new \InvalidArgumentException(sprintf("Dbal connection %s for connector %s does not exists", $connector['dbal_connection'], $connector['name']));
     }
     $connection = $this->dbalConnections->get($connector['dbal_connection']);
     if ($regenerateType) {
         $generatedTypes = $this->replaceProcessingTypes($connection->config()['dbname'], $connector['table'], $connection->connection());
     } else {
         $generatedTypes = $this->generateTypeClassFQCNs($connection->config()['dbname'], $connector['table']);
     }
     $connector['icon'] = self::ICON;
     $connector['ui_metadata_riot_tag'] = self::METADATA_UI_KEY;
     $connector['allowed_types'] = $generatedTypes;
     $connector['allowed_messages'] = [MessageNameUtils::COLLECT_DATA, MessageNameUtils::PROCESS_DATA];
     $command = ChangeConnectorConfig::ofConnector($id, $connector, $this->configLocation);
     $this->commandBus->dispatch($command);
 }
 /**
  * @param array $connection
  * @param null|string $alternativeKey
  * @throws \InvalidArgumentException
  */
 public function updateConnection(array $connection, $alternativeKey = null)
 {
     if (is_null($alternativeKey)) {
         if (!isset($connection['dbname'])) {
             throw new \InvalidArgumentException('Missing dbname key in connection configuration');
         }
         $connectionObj = $this->findByDbName($connection['dbname']);
         if (!$connectionObj) {
             throw new \InvalidArgumentException('No connection found for db: ' . $connection['dbname']);
         }
         $alternativeKey = $this->connections->indexOf($connectionObj);
     }
     Assertion::string($alternativeKey);
     if (!$this->connections->containsKey($alternativeKey)) {
         throw new \InvalidArgumentException(sprintf('Connection for DB %s can not be found', $connection['dbname']));
     }
     $this->connections->set($alternativeKey, DbalConnection::fromConfiguration($connection));
     $this->saveConnections();
 }