From 58c03832d26f12b56038b70fbe1e5a31bcf9af08 Mon Sep 17 00:00:00 2001 From: Tim Weisenberger Date: Fri, 15 Dec 2023 15:27:15 +0100 Subject: [PATCH] fix: Use TYPO3\CMS\Core\Type\Enumeration instead of backed enums, as backed enums require TYPO3 v13 --- Classes/Command/BatchCommand.php | 2 +- Classes/Domain/Model/Batch.php | 5 ++- Classes/Domain/Model/BatchState.php | 14 ------- Classes/Domain/Model/CodingResult.php | 6 +-- .../Domain/Model/CodingResultProbability.php | 12 ------ Classes/Domain/Repository/BatchRepository.php | 8 ++-- Classes/Enumerations/BatchState.php | 40 +++++++++++++++++++ .../Enumerations/CodingResultProbability.php | 25 ++++++++++++ Classes/Enumerations/GeoCoderStatus.php | 20 ++++++++++ Classes/Service/GeoCoder.php | 5 ++- Classes/Service/GeoCoderStatus.php | 11 ----- 11 files changed, 99 insertions(+), 49 deletions(-) delete mode 100644 Classes/Domain/Model/BatchState.php delete mode 100644 Classes/Domain/Model/CodingResultProbability.php create mode 100644 Classes/Enumerations/BatchState.php create mode 100644 Classes/Enumerations/CodingResultProbability.php create mode 100644 Classes/Enumerations/GeoCoderStatus.php delete mode 100644 Classes/Service/GeoCoderStatus.php diff --git a/Classes/Command/BatchCommand.php b/Classes/Command/BatchCommand.php index fb9b816..3afe4b9 100755 --- a/Classes/Command/BatchCommand.php +++ b/Classes/Command/BatchCommand.php @@ -5,8 +5,8 @@ namespace Netlogix\Nxgooglelocations\Command; use Netlogix\Nxgooglelocations\Domain\Model\Batch; -use Netlogix\Nxgooglelocations\Domain\Model\BatchState; use Netlogix\Nxgooglelocations\Domain\Repository\BatchRepository; +use Netlogix\Nxgooglelocations\Enumerations\BatchState; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; diff --git a/Classes/Domain/Model/Batch.php b/Classes/Domain/Model/Batch.php index 680c313..daf98df 100644 --- a/Classes/Domain/Model/Batch.php +++ b/Classes/Domain/Model/Batch.php @@ -6,6 +6,7 @@ use DateTime; use Exception; +use Netlogix\Nxgooglelocations\Enumerations\BatchState; use Netlogix\Nxgooglelocations\Service\BackendUserImpersonator; use Netlogix\Nxgooglelocations\Service\GeoCoder; use Netlogix\Nxgooglelocations\Service\Importer; @@ -42,7 +43,7 @@ class Batch extends AbstractEntity #[TYPO3\Transient] protected $callback; - protected BatchState $state = BatchState::NEW; + protected string $state = BatchState::NEW; protected int $amount = 0; @@ -108,7 +109,7 @@ public function cancel(): void $this->setState(BatchState::CLOSED); } - protected function setState(BatchState $state): void + protected function setState(string $state): void { $this->state = $state; $this->emitStateChange(); diff --git a/Classes/Domain/Model/BatchState.php b/Classes/Domain/Model/BatchState.php deleted file mode 100644 index 4c80bc7..0000000 --- a/Classes/Domain/Model/BatchState.php +++ /dev/null @@ -1,14 +0,0 @@ - $this->longitude, ], 'probability' => ($this->status === GeoCoderStatus::ZERO_RESULTS) - ? CodingResultProbability::ZERO_RESULTS->value + ? CodingResultProbability::ZERO_RESULTS : max( $this->minProbability, min( diff --git a/Classes/Domain/Model/CodingResultProbability.php b/Classes/Domain/Model/CodingResultProbability.php deleted file mode 100644 index a79c689..0000000 --- a/Classes/Domain/Model/CodingResultProbability.php +++ /dev/null @@ -1,12 +0,0 @@ -setQuerySettings($querySettings); - $query->matching($query->logicalNot($query->equals('state', BatchState::CLOSED->value))); + $query->matching($query->logicalNot($query->equals('state', BatchState::CLOSED))); return $query->execute(); } - public function findOneByState(BatchState $state): ?Batch + public function findOneByState(string $state): ?Batch { - return $this->findOneBy(['state' => $state->value]); + return $this->findOneBy(['state' => $state]); } } diff --git a/Classes/Enumerations/BatchState.php b/Classes/Enumerations/BatchState.php new file mode 100644 index 0000000..88e6fa7 --- /dev/null +++ b/Classes/Enumerations/BatchState.php @@ -0,0 +1,40 @@ +fieldMap->probability] = CodingResultProbability::MANUALLY_IMPORT->value; + $tcaRecord[$this->fieldMap->probability] = CodingResultProbability::MANUALLY_IMPORT; return $tcaRecord; } diff --git a/Classes/Service/GeoCoderStatus.php b/Classes/Service/GeoCoderStatus.php deleted file mode 100644 index 08da886..0000000 --- a/Classes/Service/GeoCoderStatus.php +++ /dev/null @@ -1,11 +0,0 @@ -