From c256b6343f55df3d28d91bb6b30e66846a6a9efe Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Sun, 13 Oct 2024 23:08:52 +0200 Subject: [PATCH] TASK: Describe necessity of passing CR to publishEvents --- .../Command/PerformanceMeasurementService.php | 26 ++++++++++++------- .../Classes/CommandHandlingDependencies.php | 2 +- .../Classes/ContentRepository.php | 2 +- .../Classes/EventStore/EventPersister.php | 3 ++- .../src/StructureAdjustmentService.php | 2 +- ...ricCommandExecutionAndEventPublication.php | 13 ++++++---- 6 files changed, 29 insertions(+), 19 deletions(-) diff --git a/Neos.ContentRepository.BehavioralTests/Classes/Command/PerformanceMeasurementService.php b/Neos.ContentRepository.BehavioralTests/Classes/Command/PerformanceMeasurementService.php index b11139eb9bb..b43033ebd95 100644 --- a/Neos.ContentRepository.BehavioralTests/Classes/Command/PerformanceMeasurementService.php +++ b/Neos.ContentRepository.BehavioralTests/Classes/Command/PerformanceMeasurementService.php @@ -98,21 +98,27 @@ public function createNodesForPerformanceTest(int $nodesPerLevel, int $levels): NodeAggregateClassification::CLASSIFICATION_ROOT, ); - $this->eventPersister->publishEvents($this->contentRepository, new EventsToPublish( - $this->contentStreamEventStream->getEventStreamName(), - Events::with($rootNodeAggregateWasCreated), - ExpectedVersion::ANY() - )); + $this->eventPersister->publishEvents( + new EventsToPublish( + $this->contentStreamEventStream->getEventStreamName(), + Events::with($rootNodeAggregateWasCreated), + ExpectedVersion::ANY() + ), + $this->contentRepository + ); #$time = microtime(true); $sumSoFar = 0; $events = []; $this->createHierarchy($rootNodeAggregateId, 1, $levels, $nodesPerLevel, $sumSoFar, $events); - $this->eventPersister->publishEvents($this->contentRepository, new EventsToPublish( - $this->contentStreamEventStream->getEventStreamName(), - Events::fromArray($events), - ExpectedVersion::ANY() - )); + $this->eventPersister->publishEvents( + new EventsToPublish( + $this->contentStreamEventStream->getEventStreamName(), + Events::fromArray($events), + ExpectedVersion::ANY() + ), + $this->contentRepository + ); echo $sumSoFar; #$this->outputLine(microtime(true) - $time . ' elapsed'); } diff --git a/Neos.ContentRepository.Core/Classes/CommandHandlingDependencies.php b/Neos.ContentRepository.Core/Classes/CommandHandlingDependencies.php index 732681a8ee4..90e9e4249cf 100644 --- a/Neos.ContentRepository.Core/Classes/CommandHandlingDependencies.php +++ b/Neos.ContentRepository.Core/Classes/CommandHandlingDependencies.php @@ -52,7 +52,7 @@ public function handle(CommandInterface $command): CommandResult public function publishEvents(EventsToPublish $eventsToPublish): void { - $this->eventPersister->publishEvents($this->contentRepository, $eventsToPublish); + $this->eventPersister->publishEvents($eventsToPublish, $this->contentRepository); } public function getWorkspaceFinder(): WorkspaceFinder diff --git a/Neos.ContentRepository.Core/Classes/ContentRepository.php b/Neos.ContentRepository.Core/Classes/ContentRepository.php index 703dd6bdb4e..c8c54b3e67f 100644 --- a/Neos.ContentRepository.Core/Classes/ContentRepository.php +++ b/Neos.ContentRepository.Core/Classes/ContentRepository.php @@ -129,7 +129,7 @@ public function handle(CommandInterface $command): CommandResult $eventsToPublish->expectedVersion, ); - return $this->eventPersister->publishEvents($this, $eventsToPublish); + return $this->eventPersister->publishEvents($eventsToPublish, $this); } diff --git a/Neos.ContentRepository.Core/Classes/EventStore/EventPersister.php b/Neos.ContentRepository.Core/Classes/EventStore/EventPersister.php index 5971bc52c1a..df65cdd7947 100644 --- a/Neos.ContentRepository.Core/Classes/EventStore/EventPersister.php +++ b/Neos.ContentRepository.Core/Classes/EventStore/EventPersister.php @@ -35,10 +35,11 @@ public function __construct( /** * @param EventsToPublish $eventsToPublish + * @param ContentRepository $contentRepository only required to build the possible catchup hooks * @return CommandResult * @throws ConcurrencyException in case the expectedVersion does not match */ - public function publishEvents(ContentRepository $contentRepository, EventsToPublish $eventsToPublish): CommandResult + public function publishEvents(EventsToPublish $eventsToPublish, ContentRepository $contentRepository): CommandResult { if ($eventsToPublish->events->isEmpty()) { return new CommandResult(); diff --git a/Neos.ContentRepository.StructureAdjustment/src/StructureAdjustmentService.php b/Neos.ContentRepository.StructureAdjustment/src/StructureAdjustmentService.php index 6211faa4751..3579ead7057 100644 --- a/Neos.ContentRepository.StructureAdjustment/src/StructureAdjustmentService.php +++ b/Neos.ContentRepository.StructureAdjustment/src/StructureAdjustmentService.php @@ -102,7 +102,7 @@ public function fixError(StructureAdjustment $adjustment): void $remediation = $adjustment->remediation; $eventsToPublish = $remediation(); assert($eventsToPublish instanceof EventsToPublish); - $this->eventPersister->publishEvents($this->contentRepository, $eventsToPublish); + $this->eventPersister->publishEvents($eventsToPublish, $this->contentRepository); } } } diff --git a/Neos.ContentRepository.TestSuite/Classes/Behavior/Features/Bootstrap/GenericCommandExecutionAndEventPublication.php b/Neos.ContentRepository.TestSuite/Classes/Behavior/Features/Bootstrap/GenericCommandExecutionAndEventPublication.php index bc49c4c9e37..8ddbb0e9336 100644 --- a/Neos.ContentRepository.TestSuite/Classes/Behavior/Features/Bootstrap/GenericCommandExecutionAndEventPublication.php +++ b/Neos.ContentRepository.TestSuite/Classes/Behavior/Features/Bootstrap/GenericCommandExecutionAndEventPublication.php @@ -140,11 +140,14 @@ protected function publishEvent(string $eventType, StreamName $streamName, array ->getValue($eventPersister); $event = $eventNormalizer->denormalize($artificiallyConstructedEvent); - $eventPersister->publishEvents($this->currentContentRepository, new EventsToPublish( - $streamName, - Events::with($event), - ExpectedVersion::ANY() - )); + $eventPersister->publishEvents( + new EventsToPublish( + $streamName, + Events::with($event), + ExpectedVersion::ANY() + ), + $this->currentContentRepository + ); } /**