public function startAppAction()
 {
     $view = new ViewModel(['sql_connectors' => $this->getSqlConnectorsForClient(), 'dbal_connections' => array_values($this->dbalConnections->toArray())]);
     $view->setTemplate('prooph.link.sqlconnector/sql-manager/app');
     $this->layout()->setVariable('includeRiotJs', true);
     return $view;
 }
 private function saveConnections($checkFile = false)
 {
     $path = $this->configLocation->toString() . DIRECTORY_SEPARATOR . self::FILE_NAME;
     $config = ['prooph.link.sqlconnector' => ['connections' => $this->connections->toArray()]];
     if ($checkFile && !file_exists($path)) {
         $this->configWriter->writeNewConfigToDirectory($config, $path);
     } else {
         $this->configWriter->replaceConfigInDirectory($config, $path);
     }
 }
 protected function setUp()
 {
     $this->connection = DbalConnection::fromConfiguration(['driver' => 'pdo_sqlite', 'memory' => true, 'dbname' => 'test_db']);
     $testDataTable = new Table("test_data");
     $testDataTable->addColumn("name", "string");
     $testDataTable->addColumn("age", "integer");
     $testDataTable->addColumn("created_at", "datetime");
     $testDataTable->addColumn("price", "float");
     $testDataTable->addColumn("active", "boolean");
     $testDataTable->setPrimaryKey(["name"]);
     $this->connection->connection()->getSchemaManager()->createTable($testDataTable);
     $this->dataTypeLocation = ApplicationDataTypeLocation::fromPath(sys_get_temp_dir());
     $this->commandBus = new CommandBusMock();
     if (!is_dir(sys_get_temp_dir() . "/SqlConnector")) {
         mkdir(sys_get_temp_dir() . "/SqlConnector");
         mkdir(sys_get_temp_dir() . "/SqlConnector/DataType");
     }
     $connections = new DbalConnectionCollection();
     $connections->add($this->connection);
     $this->tableConnectorGenerator = new TableConnectorGenerator($connections, $this->dataTypeLocation, ConfigLocation::fromPath(sys_get_temp_dir()), $this->commandBus, Bootstrap::getServiceManager()->get("config")['prooph.link.sqlconnector']['doctrine_processing_type_map']);
 }
 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);
 }
 /**
  * Create service
  *
  * @param ServiceLocatorInterface $serviceLocator
  * @return mixed
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $appConfig = $serviceLocator->get('config');
     return DbalConnectionCollection::fromConnectionConfigs($appConfig['prooph.link.sqlconnector']['connections']);
 }