Skip to content

Commit

Permalink
TASK: Fixup cherry-pick and adjust to use CommandHandlingDependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsdesign committed Oct 14, 2024
1 parent 2a717fd commit ddac2c4
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

use Neos\ContentRepository\Core\CommandHandler\CommandInterface;
use Neos\ContentRepository\Core\CommandHandler\CommandResult;
use Neos\ContentRepository\Core\EventStore\EventPersister;
use Neos\ContentRepository\Core\EventStore\EventsToPublish;
use Neos\ContentRepository\Core\Projection\ContentGraph\ContentGraphInterface;
use Neos\ContentRepository\Core\Projection\ContentStream\ContentStreamFinder;
use Neos\ContentRepository\Core\Projection\Workspace\WorkspaceFinder;
Expand All @@ -37,15 +39,22 @@ final class CommandHandlingDependencies
*/
private array $overridenContentGraphInstances = [];

public function __construct(private readonly ContentRepository $contentRepository)
{
public function __construct(
private readonly ContentRepository $contentRepository,
private readonly EventPersister $eventPersister
) {
}

public function handle(CommandInterface $command): CommandResult
{
return $this->contentRepository->handle($command);
}

public function publishEvents(EventsToPublish $eventsToPublish): void
{
$this->eventPersister->publishEvents($this->contentRepository, $eventsToPublish);
}

public function getWorkspaceFinder(): WorkspaceFinder
{
return $this->contentRepository->getWorkspaceFinder();
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 @@ -87,7 +87,7 @@ public function __construct(
private readonly UserIdProviderInterface $userIdProvider,
private readonly ClockInterface $clock,
) {
$this->commandHandlingDependencies = new CommandHandlingDependencies($this);
$this->commandHandlingDependencies = new CommandHandlingDependencies($this, $eventPersister);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
public function __construct(
private EventStoreInterface $eventStore,
private EventNormalizer $eventNormalizer,
private Projections $projections,
) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ private function buildCommandBus(): CommandBus
new ContentStreamCommandHandler(
),
new WorkspaceCommandHandler(
$this->buildEventPersister(),
$this->projectionFactoryDependencies->eventStore,
$this->projectionFactoryDependencies->eventNormalizer,
),
Expand Down Expand Up @@ -165,7 +164,6 @@ private function buildEventPersister(): EventPersister
$this->eventPersister = new EventPersister(
$this->projectionFactoryDependencies->eventStore,
$this->projectionFactoryDependencies->eventNormalizer,
$this->projectionsAndCatchUpHooks->projections,
);
}
return $this->eventPersister;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@
final readonly class WorkspaceCommandHandler implements CommandHandlerInterface
{
public function __construct(
private EventPersister $eventPersister,
private EventStoreInterface $eventStore,
private EventNormalizer $eventNormalizer,
) {
Expand Down Expand Up @@ -240,7 +239,7 @@ private function handlePublishWorkspace(
$baseWorkspace = $this->requireBaseWorkspace($workspace, $commandHandlingDependencies->getWorkspaceFinder());

$this->publishContentStream(
$contentRepository,
$commandHandlingDependencies,
$workspace->currentContentStreamId,
$baseWorkspace->workspaceName,
$baseWorkspace->currentContentStreamId
Expand Down Expand Up @@ -277,11 +276,11 @@ private function handlePublishWorkspace(
* @throws \Exception
*/
private function publishContentStream(
ContentRepository $contentRepository,
CommandHandlingDependencies $commandHandlingDependencies,
ContentStreamId $contentStreamId,
WorkspaceName $baseWorkspaceName,
ContentStreamId $baseContentStreamId,
): ?CommandResult {
): void {
$baseWorkspaceContentStreamName = ContentStreamEventStreamName::fromContentStreamId(
$baseContentStreamId
);
Expand Down Expand Up @@ -326,11 +325,10 @@ private function publishContentStream(
}

if (count($events) === 0) {
return null;
return;
}
try {
return $this->eventPersister->publishEvents(
$contentRepository,
$commandHandlingDependencies->publishEvents(
new EventsToPublish(
$baseWorkspaceContentStreamName->getEventStreamName(),
Events::fromArray($events),
Expand Down Expand Up @@ -543,7 +541,7 @@ function () use ($matchingCommands, $commandHandlingDependencies, $baseWorkspace

// 5) take EVENTS(MATCHING) and apply them to base WS.
$this->publishContentStream(
$contentRepository,
$commandHandlingDependencies,
$command->contentStreamIdForMatchingPart,
$baseWorkspace->workspaceName,
$baseWorkspace->currentContentStreamId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class StructureAdjustmentService implements ContentRepositoryServiceInterface
private readonly ContentGraphInterface $liveContentGraph;

public function __construct(
ContentRepository $contentRepository,
private readonly ContentRepository $contentRepository,
private readonly EventPersister $eventPersister,
NodeTypeManager $nodeTypeManager,
InterDimensionalVariationGraph $interDimensionalVariationGraph,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@
* is not needed:
*
* By calling {@see self::disabled(\Closure)} in your code, all projection updates
* will never trigger catch up hooks. This will only work when
* {@see CatchUpTriggerWithSynchronousOption::synchronously()} is called,
* as otherwise this subprocess won't be called.
* will never trigger catch up hooks.
*
*
* projection update
Expand Down

0 comments on commit ddac2c4

Please sign in to comment.