/** * @param SqliteDbFile $sqliteDbFile * @param ConfigLocation $configLocation * @param ConfigWriter $configWriter * @return EventStoreConfig */ public static function initializeWithSqliteDb(SqliteDbFile $sqliteDbFile, ConfigLocation $configLocation, ConfigWriter $configWriter) { $config = ['proophessor' => ['event_store' => ['adapter' => ['type' => 'Prooph\\EventStore\\Adapter\\Doctrine\\DoctrineEventStoreAdapter', 'options' => ['connection' => ['driver' => 'pdo_sqlite', 'path' => $sqliteDbFile->toString()], 'serializer_adapter' => 'json']]]]]; $instance = new self($config, $configLocation); $configWriter->writeNewConfigToDirectory($config, $configLocation->toString() . DIRECTORY_SEPARATOR . $instance->configFileName()); $instance->recordThat(EventStoreWasInitialized::withSqliteDb($sqliteDbFile, $configLocation, $instance->configFileName())); return $instance; }
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); } }
/** * Handles a POST request to enable or disable the workflow processor message queue */ public function configureWorkflowProcessorMessageQueueAction() { $queueEnabled = $this->bodyParam('enabled'); if (!is_bool($queueEnabled)) { return new ApiProblemResponse(new ApiProblem(422, $this->translator->translate('The enabled flag should be a boolean value'))); } if ($queueEnabled) { $this->commandBus->dispatch(EnableWorkflowProcessorMessageQueue::in(ConfigLocation::fromPath(Definition::getSystemConfigDir()))); } else { $this->commandBus->dispatch(DisableWorkflowProcessorMessageQueue::in(ConfigLocation::fromPath(Definition::getSystemConfigDir()))); } return ['success' => true]; }
/** * Runs the initial set up of the processing system */ public function runAction() { try { $this->commandBus->dispatch(CreateDefaultProcessingConfigFile::in(ConfigLocation::fromPath(Definition::getSystemConfigDir()))); $sqliteDbFile = SqliteDbFile::initializeFromDist(Definition::getEventStoreSqliteDbFile()); $esConfigLocation = ConfigLocation::fromPath(Definition::getSystemConfigDir()); $this->commandBus->dispatch(InitializeEventStore::setUpWithSqliteDbAdapter($sqliteDbFile, $esConfigLocation)); } catch (\Exception $ex) { $this->commandBus->dispatch(UndoSystemSetUp::removeConfigs(Definition::getSystemConfigDir(), Definition::getSystemConfigDir(), Definition::getEventStoreSqliteDbFile())); throw $ex; } return $this->redirect()->toRoute('prooph.link/system_config'); }
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']); }
/** * Create service * * @param ServiceLocatorInterface $serviceLocator * @return mixed */ public function createService(ServiceLocatorInterface $serviceLocator) { return ConfigLocation::fromPath($serviceLocator->get('config')['system_config_dir']); }
/** * @param ConfigLocation $configLocation * @return EnableWorkflowProcessorMessageQueue */ public static function in(ConfigLocation $configLocation) { return new self(__CLASS__, ['config_location' => $configLocation->toString()]); }
/** * @param string $messageName * @param ConfigLocation $configLocation * @return RemoveProcessConfig */ public static function ofProcessTriggeredByMessage($messageName, ConfigLocation $configLocation) { return new self(__CLASS__, ['start_message' => $messageName, 'config_location' => $configLocation->toString()]); }
/** * @param $connectorId * @param $connectorName * @param array $allowedMessages * @param array $allowedTypes * @param ConfigLocation $configLocation * @param array $additionalData * @return AddConnectorToConfig */ public static function fromDefinition($connectorId, $connectorName, array $allowedMessages, array $allowedTypes, ConfigLocation $configLocation, array $additionalData = array()) { return new self(__CLASS__, ['connector_id' => $connectorId, 'connector_name' => $connectorName, 'allowed_messages' => $allowedMessages, 'allowed_types' => $allowedTypes, 'additional_data' => $additionalData, 'config_location' => $configLocation->toString()]); }
/** * @param string $name * @param string $processType * @param string $startMessage * @param array $tasks * @param ConfigLocation $configLocation * @return AddNewProcessToConfig */ public static function fromDefinition($name, $processType, $startMessage, array $tasks, ConfigLocation $configLocation) { return new self(__CLASS__, ["name" => $name, "process_type" => $processType, "start_message" => $startMessage, "tasks" => $tasks, "config_location" => $configLocation->toString()]); }
/** * @return bool */ public function isWritable() { return is_writable($this->configLocation->toString() . DIRECTORY_SEPARATOR . \Prooph\Link\Application\Model\ProcessingConfig::configFileName()); }
/** * @param SqliteDbFile $sqliteDbFile * @param ConfigLocation $configLocation * @param $fileName * @return EventStoreWasInitialized */ public static function withSqliteDb(SqliteDbFile $sqliteDbFile, ConfigLocation $configLocation, $fileName) { return self::occur(['config_file' => $configLocation->toString() . DIRECTORY_SEPARATOR . $fileName, 'sqlite_db_file' => $sqliteDbFile->toString()]); }
/** * @param ConfigLocation $configLocation * @param string $fileName * @return static */ public static function in(ConfigLocation $configLocation, $fileName) { return self::occur(['config_file' => $configLocation->toString() . DIRECTORY_SEPARATOR . $fileName]); }
/** * @param SqliteDbFile $sqliteDbFile * @param ConfigLocation $eventStoreConfigLocation * @return InitializeEventStore */ public static function setUpWithSqliteDbAdapter(SqliteDbFile $sqliteDbFile, ConfigLocation $eventStoreConfigLocation) { return new self(__CLASS__, ['sqlite_db_file' => $sqliteDbFile->toString(), 'config_location' => $eventStoreConfigLocation->toString()]); }
/** * @return ConfigLocation */ public function configLocation() { return ConfigLocation::fromPath($this->payload['config_location']); }
/** * @param bool $enabled * @param int $interval * @param ConfigLocation $configLocation * @return ConfigureJavascriptTicker */ public static function set($enabled, $interval, ConfigLocation $configLocation) { return new self(__CLASS__, ['enabled' => $enabled, 'interval' => $interval, 'config_location' => $configLocation->toString()]); }
/** * Write config to file with the help of a config writer * * @param ConfigWriter $configWriter */ private function writeConfig(ConfigWriter $configWriter) { $configWriter->replaceConfigInDirectory($this->toArray(), $this->configLocation->toString() . DIRECTORY_SEPARATOR . self::$configFileName); }
public static function ofConnector($connectorId, array $connectorConfig, ConfigLocation $configLocation) { return new self(__CLASS__, ['connector_id' => $connectorId, 'connector_config' => $connectorConfig, 'config_location' => $configLocation->toString()]); }
/** * @param NodeName $newNodeName * @param ConfigLocation $configLocation * @return ChangeNodeName */ public static function to(NodeName $newNodeName, ConfigLocation $configLocation) { return new self(__CLASS__, ['node_name' => $newNodeName->toString(), 'config_location' => $configLocation->toString()]); }
/** * @param ConfigLocation $configLocation * @return CreateDefaultProcessingConfigFile * @throws \InvalidArgumentException */ public static function in(ConfigLocation $configLocation) { $instance = new self(__CLASS__, ['config_location' => $configLocation->toString()]); $instance->configLocation = $configLocation; return $instance; }