diff --git a/composer.json b/composer.json index ef643fb0..6c7413ed 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,6 @@ "erusev/parsedown": "^1.7", "friendsofsymfony/jsrouting-bundle": "^3.3", "knpuniversity/oauth2-client-bundle": "^2.15", - "league/csv": "^9.10", "nelmio/cors-bundle": "^2.3", "phpdocumentor/reflection-docblock": "^5.3", "phpstan/phpdoc-parser": "^1.25", diff --git a/composer.lock b/composer.lock index 9338f923..09c3ee64 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "b51c778d94f5639fa4471a508ddc6886", + "content-hash": "e1500511816191be966b64c436d67798", "packages": [ { "name": "api-platform/core", @@ -2384,94 +2384,6 @@ }, "time": "2023-05-03T16:44:38+00:00" }, - { - "name": "league/csv", - "version": "9.10.0", - "source": { - "type": "git", - "url": "https://github.com/thephpleague/csv.git", - "reference": "d24b0d484812313b07ab74b0fe4db9661606df6c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/thephpleague/csv/zipball/d24b0d484812313b07ab74b0fe4db9661606df6c", - "reference": "d24b0d484812313b07ab74b0fe4db9661606df6c", - "shasum": "" - }, - "require": { - "ext-json": "*", - "ext-mbstring": "*", - "php": "^8.1.2" - }, - "require-dev": { - "doctrine/collections": "^2.1.3", - "ext-dom": "*", - "ext-xdebug": "*", - "friendsofphp/php-cs-fixer": "^v3.22.0", - "phpbench/phpbench": "^1.2.14", - "phpstan/phpstan": "^1.10.26", - "phpstan/phpstan-deprecation-rules": "^1.1.3", - "phpstan/phpstan-phpunit": "^1.3.13", - "phpstan/phpstan-strict-rules": "^1.5.1", - "phpunit/phpunit": "^10.3.1", - "symfony/var-dumper": "^6.3.3" - }, - "suggest": { - "ext-dom": "Required to use the XMLConverter and the HTMLConverter classes", - "ext-iconv": "Needed to ease transcoding CSV using iconv stream filters" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "9.x-dev" - } - }, - "autoload": { - "files": [ - "src/functions_include.php" - ], - "psr-4": { - "League\\Csv\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Ignace Nyamagana Butera", - "email": "nyamsprod@gmail.com", - "homepage": "https://github.com/nyamsprod/", - "role": "Developer" - } - ], - "description": "CSV data manipulation made easy in PHP", - "homepage": "https://csv.thephpleague.com", - "keywords": [ - "convert", - "csv", - "export", - "filter", - "import", - "read", - "transform", - "write" - ], - "support": { - "docs": "https://csv.thephpleague.com", - "issues": "https://github.com/thephpleague/csv/issues", - "rss": "https://github.com/thephpleague/csv/releases.atom", - "source": "https://github.com/thephpleague/csv" - }, - "funding": [ - { - "url": "https://github.com/sponsors/nyamsprod", - "type": "github" - } - ], - "time": "2023-08-04T15:12:48+00:00" - }, { "name": "league/oauth2-client", "version": "2.7.0", diff --git a/src/Command/ImportModListsCommand.php b/src/Command/ImportModListsCommand.php deleted file mode 100644 index 3fc4a681..00000000 --- a/src/Command/ImportModListsCommand.php +++ /dev/null @@ -1,42 +0,0 @@ -setName('app:import:modlists') - ->setDescription('Imports mods') - ->addArgument( - 'path', - InputArgument::REQUIRED, - 'Path to directory with CSV files', - ) - ; - } - - protected function execute(InputInterface $input, OutputInterface $output): int - { - $path = $input->getArgument('path'); - - $this->modListImport->importFromDirectory($path); - - return 0; - } -} diff --git a/src/Service/LegacyModListImport/Dto/ModCsvEntryDto.php b/src/Service/LegacyModListImport/Dto/ModCsvEntryDto.php deleted file mode 100644 index 7828fbb1..00000000 --- a/src/Service/LegacyModListImport/Dto/ModCsvEntryDto.php +++ /dev/null @@ -1,42 +0,0 @@ -id; - } - - public function getName(): string - { - return $this->name; - } - - public function getIsServerSide(): ?string - { - return $this->isServerSide; - } - - public function getIsOptional(): ?string - { - return $this->isOptional; - } - - public function getIsMap(): ?string - { - return $this->isMap; - } -} diff --git a/src/Service/LegacyModListImport/DtoToEntityConverter.php b/src/Service/LegacyModListImport/DtoToEntityConverter.php deleted file mode 100644 index 90a4c911..00000000 --- a/src/Service/LegacyModListImport/DtoToEntityConverter.php +++ /dev/null @@ -1,43 +0,0 @@ -getId(); - $isSteamWorkshopMod = 'local' !== strtolower($id); - $name = trim($modCsvEntryDto->getName()); - $isOptional = 'true' === strtolower($modCsvEntryDto->getIsOptional()); - $isServerSide = 'true' === strtolower($modCsvEntryDto->getIsServerSide()); - $isMap = 'true' === strtolower($modCsvEntryDto->getIsServerSide()); - - $modType = ModTypeEnum::REQUIRED; - if ($isServerSide) { - $modType = ModTypeEnum::SERVER_SIDE; - } elseif ($isMap) { - $modType = ModTypeEnum::OPTIONAL; - } elseif ($isOptional) { - $modType = ModTypeEnum::CLIENT_SIDE; - } - - if ($isSteamWorkshopMod) { - return new SteamWorkshopMod(Uuid::uuid4(), $name, null, null, $modType, (int) $id); - } - - return new DirectoryMod(Uuid::uuid4(), $name, null, null, $name); - } -} diff --git a/src/Service/LegacyModListImport/DtoToEntityConverterInterface.php b/src/Service/LegacyModListImport/DtoToEntityConverterInterface.php deleted file mode 100644 index 9e3494d3..00000000 --- a/src/Service/LegacyModListImport/DtoToEntityConverterInterface.php +++ /dev/null @@ -1,13 +0,0 @@ -setDelimiter($delimiter); - - /** @var array[] $rows */ - $rows = $reader->getRecords(); - - foreach ($rows as $row) { - if (!$this->isRowValid($row)) { - continue; - } - - yield new ModCsvEntryDto( - $row[self::COLUMN_INDEX_ID], - $row[self::COLUMN_INDEX_NAME], - $row[self::COLUMN_INDEX_IS_SERVER_SIDE], - $row[self::COLUMN_INDEX_IS_OPTIONAL], - $row[self::COLUMN_INDEX_IS_MAP] - ); - } - } - - /** - * @param string[] $row - */ - protected function isRowValid(array $row): bool - { - $id = $row[self::COLUMN_INDEX_ID]; - - return 'local' === strtolower($id) || is_numeric($id); - } -} diff --git a/src/Service/LegacyModListImport/ModListCsvReaderInterface.php b/src/Service/LegacyModListImport/ModListCsvReaderInterface.php deleted file mode 100644 index 28fe93ad..00000000 --- a/src/Service/LegacyModListImport/ModListCsvReaderInterface.php +++ /dev/null @@ -1,10 +0,0 @@ -findFilesToImport($path, $extension); - foreach ($files as $file) { - $filePath = $file->getPathname(); - $baseName = $file->getBasename($extension); - - $mods = []; - foreach ($this->modListCsvReader->readCsvRow($filePath) as $modCsvEntryDto) { - $modEntity = $this->dtoToEntityConverter->convert($modCsvEntryDto); - - $existingMod = null; - if ($modEntity instanceof SteamWorkshopMod) { - $existingMod = $this->steamWorkshopModRepository->findOneByItemId($modEntity->getItemId()); - } elseif ($modEntity instanceof DirectoryMod) { - $existingMod = $this->directoryModRepository->findOneByDirectory($modEntity->getDirectory()); - } - - $mods[] = $existingMod ?? $modEntity; - } - - $modList = new ModList( - Uuid::uuid4(), - $baseName, - null, - $mods, - [], - [], - null, - true, - false - ); - - if (\count($modList->getMods()) > 0) { - $this->entityManager->persist($modList); - } - - $this->entityManager->flush(); - } - } - - /** - * @return \SplFileInfo[] - */ - protected function findFilesToImport(string $path, string $extension): iterable - { - $finder = new Finder(); - $files = $finder->in($path)->files()->name("*{$extension}"); - - return $files->getIterator(); - } -} diff --git a/src/Service/LegacyModListImport/ModListImportInterface.php b/src/Service/LegacyModListImport/ModListImportInterface.php deleted file mode 100644 index 23338470..00000000 --- a/src/Service/LegacyModListImport/ModListImportInterface.php +++ /dev/null @@ -1,10 +0,0 @@ -