/** * Does the same like generateProcessingTypesIfNotExist but overrides any existing type classes. * Use this method with care. * * @param string $dbname * @param string $table * @param Connection $connection * @return array */ private function replaceProcessingTypes($dbname, $table, Connection $connection) { $dbNsName = $this->titleize($dbname); $rowClassName = $this->titleize($table); $collectionClassName = $rowClassName . "Collection"; $namespace = 'Prooph\\Link\\Application\\DataType\\SqlConnector\\' . $dbNsName; $this->dataTypeLocation->addDataTypeClass($namespace . '\\' . $rowClassName, $this->generateRowTypeClass($namespace, $rowClassName, $table, $connection), $forceReplace = true); $this->dataTypeLocation->addDataTypeClass($namespace . '\\' . $collectionClassName, $this->generateRowCollectionTypeClass($namespace, $collectionClassName, $rowClassName), $forceReplace = true); return [$namespace . '\\' . $rowClassName, $namespace . '\\' . $collectionClassName]; }
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 ApplicationDataTypeLocation::fromPath($serviceLocator->get('config')['system_data_type_dir']); }