Skip to content

Commit

Permalink
TASK: Remove CommandHandlingDependencies::publishEvents
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsdesign committed Oct 21, 2024
1 parent 36f18ab commit d3119b8
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
namespace Neos\ContentRepository\Core;

use Neos\ContentRepository\Core\CommandHandler\CommandInterface;
use Neos\ContentRepository\Core\EventStore\EventPersister;
use Neos\ContentRepository\Core\EventStore\EventsToPublish;
use Neos\ContentRepository\Core\Projection\ContentGraph\ContentGraphInterface;
use Neos\ContentRepository\Core\SharedModel\Workspace\Workspace;
use Neos\ContentRepository\Core\SharedModel\Exception\WorkspaceDoesNotExist;
Expand All @@ -40,8 +38,7 @@ final class CommandHandlingDependencies
private array $overriddenContentGraphInstances = [];

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

Expand All @@ -50,11 +47,6 @@ public function handle(CommandInterface $command): void
$this->contentRepository->handle($command);
}

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

public function getContentStreamVersion(ContentStreamId $contentStreamId): Version
{
$contentStream = $this->contentRepository->findContentStreamById($contentStreamId);
Expand Down Expand Up @@ -119,4 +111,12 @@ public function overrideContentStreamId(WorkspaceName $workspaceName, ContentStr
unset($this->overriddenContentGraphInstances[$workspaceName->value]);
}
}

/**
* Fixme only required to build the possible catchup hooks
*/
public function getContentRepository(): ContentRepository
{
return $this->contentRepository;
}
}
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, $eventPersister);
$this->commandHandlingDependencies = new CommandHandlingDependencies($this);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ private function buildCommandBus(): CommandBus
new ContentStreamCommandHandler(
),
new WorkspaceCommandHandler(
$this->buildEventPersister(),
$this->projectionFactoryDependencies->eventStore,
$this->projectionFactoryDependencies->eventNormalizer,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
final readonly class WorkspaceCommandHandler implements CommandHandlerInterface
{
public function __construct(
private EventPersister $eventPersister,
private EventStoreInterface $eventStore,
private EventNormalizer $eventNormalizer,
) {
Expand Down Expand Up @@ -289,7 +290,8 @@ private function publishContentStream(
return;
}
try {
$commandHandlingDependencies->publishEvents(
$this->eventPersister->publishEvents(
$commandHandlingDependencies->getContentRepository(),
new EventsToPublish(
$baseWorkspaceContentStreamName->getEventStreamName(),
Events::fromArray($events),
Expand Down

0 comments on commit d3119b8

Please sign in to comment.