Skip to content

Commit

Permalink
[TASK] Make DataHandlerHook stateless
Browse files Browse the repository at this point in the history
Fixes #3648
  • Loading branch information
oliverklee committed Oct 4, 2024
1 parent e05989c commit 3baa835
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 6 additions & 9 deletions Classes/Hooks/DataHandlerHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -54,31 +52,30 @@ 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);
}
}

/**
* @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];
}

/**
Expand Down

0 comments on commit 3baa835

Please sign in to comment.