From 3baa8354a1d824fc4431774cfe9c5253241a6c97 Mon Sep 17 00:00:00 2001 From: Oliver Klee Date: Fri, 4 Oct 2024 17:52:48 +0200 Subject: [PATCH] [TASK] Make `DataHandlerHook` stateless Fixes #3648 --- CHANGELOG.md | 1 + Classes/Hooks/DataHandlerHook.php | 15 ++++++--------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 98e2e4da6..ef46156df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ This project adheres to [Semantic Versioning](https://semver.org/). ### Changed +- Make `DataHandlerHook` stateless (#3774) - Merge `Csv/AbstractListView` into `Csv/AbstractRegistrationListView` (#3771) - Convert the manual to the new PHP-based rendering (#3692, #3696) - Use PHP 7.4 language features and native type declarations diff --git a/Classes/Hooks/DataHandlerHook.php b/Classes/Hooks/DataHandlerHook.php index 6545fc762..7416141ab 100644 --- a/Classes/Hooks/DataHandlerHook.php +++ b/Classes/Hooks/DataHandlerHook.php @@ -38,8 +38,6 @@ class DataHandlerHook implements SingletonInterface */ private const TABLE_PLACES_ASSOCIATION = 'tx_seminars_seminars_place_mm'; - private DataHandler $dataHandler; - private SlugGenerator $slugGenerator; public function __construct(SlugGenerator $slugGenerator) @@ -54,19 +52,18 @@ public function __construct(SlugGenerator $slugGenerator) */ public function processDatamap_afterAllOperations(DataHandler $dataHandler): void { - $this->dataHandler = $dataHandler; - $this->processEvents(); + $this->processEvents($dataHandler); } /** * Processes all events. */ - private function processEvents(): void + private function processEvents(DataHandler $dataHandler): void { - $map = ($this->dataHandler->datamap[self::TABLE_EVENTS] ?? []); + $map = $dataHandler->datamap[self::TABLE_EVENTS] ?? []; foreach ($map as $possibleUid => $data) { - $uid = $this->createRealUid($possibleUid); + $uid = $this->createRealUid($possibleUid, $dataHandler); $this->processSingleEvent($uid); } } @@ -74,11 +71,11 @@ private function processEvents(): void /** * @param int|string $possibleUid */ - private function createRealUid($possibleUid): int + private function createRealUid($possibleUid, DataHandler $dataHandler): int { return $this->isRealUid($possibleUid) ? (int)$possibleUid - : (int)$this->dataHandler->substNEWwithIDs[$possibleUid]; + : (int)$dataHandler->substNEWwithIDs[$possibleUid]; } /**