Skip to content

Commit

Permalink
TASK: Describe necessity of passing CR to publishEvents
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsdesign committed Oct 13, 2024
1 parent 1bd06fd commit c256b63
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Neos.ContentRepository.Core/Classes/ContentRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public function handle(CommandInterface $command): CommandResult
$eventsToPublish->expectedVersion,
);

return $this->eventPersister->publishEvents($this, $eventsToPublish);
return $this->eventPersister->publishEvents($eventsToPublish, $this);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}

/**
Expand Down

0 comments on commit c256b63

Please sign in to comment.