Skip to content

Commit

Permalink
remove EventPersister and much more :)
Browse files Browse the repository at this point in the history
  • Loading branch information
bwaidelich committed Nov 14, 2024
1 parent 8d64dd7 commit c393957
Showing 1 changed file with 22 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePointSet;
use Neos\ContentRepository\Core\DimensionSpace\OriginDimensionSpacePoint;
use Neos\ContentRepository\Core\EventStore\EventNormalizer;
use Neos\ContentRepository\Core\EventStore\EventPersister;
use Neos\ContentRepository\Core\EventStore\Events;
use Neos\ContentRepository\Core\EventStore\EventsToPublish;
use Neos\ContentRepository\Core\Factory\ContentRepositoryServiceFactoryDependencies;
use Neos\ContentRepository\Core\Factory\ContentRepositoryServiceFactoryInterface;
use Neos\ContentRepository\Core\Factory\ContentRepositoryServiceInterface;
use Neos\ContentRepository\Core\Feature\Common\RebasableToOtherWorkspaceInterface;
use Neos\ContentRepository\Core\Feature\DimensionSpaceAdjustment\Command\AddDimensionShineThrough;
use Neos\ContentRepository\Core\Feature\DimensionSpaceAdjustment\Command\MoveDimensionSpacePoint;
Expand Down Expand Up @@ -56,10 +56,12 @@
use Neos\ContentRepository\Core\Feature\WorkspaceRebase\Exception\WorkspaceRebaseFailed;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId;
use Neos\ContentRepository\Core\SharedModel\Node\ReferenceName;
use Neos\ContentRepository\Core\Subscription\Engine\SubscriptionEngine;
use Neos\EventStore\EventStoreInterface;
use Neos\EventStore\Model\Event;
use Neos\EventStore\Model\Event\StreamName;
use Neos\EventStore\Model\EventEnvelope;
use Neos\EventStore\Model\Events;
use Neos\EventStore\Model\EventStream\ExpectedVersion;
use Neos\EventStore\Model\EventStream\VirtualStreamName;
use Neos\Utility\Arrays;
Expand Down Expand Up @@ -286,19 +288,23 @@ protected function publishEvent(string $eventType, StreamName $streamName, array
Event\EventData::fromString(json_encode($eventPayload)),
Event\EventMetadata::fromArray([])
);
/** @var EventPersister $eventPersister */
$eventPersister = (new \ReflectionClass($this->currentContentRepository))->getProperty('eventPersister')
->getValue($this->currentContentRepository);
/** @var EventNormalizer $eventNormalizer */
$eventNormalizer = (new \ReflectionClass($eventPersister))->getProperty('eventNormalizer')
->getValue($eventPersister);
$event = $eventNormalizer->denormalize($artificiallyConstructedEvent);

$eventPersister->publishEvents($this->currentContentRepository, new EventsToPublish(
$streamName,
Events::with($event),
ExpectedVersion::ANY()
));

// HACK can be replaced, once https://github.com/neos/neos-development-collection/pull/5341 is merged
$eventStoreAndSubscriptionEngine = new class implements ContentRepositoryServiceFactoryInterface {
public EventStoreInterface|null $eventStore;
public SubscriptionEngine|null $subscriptionEngine;
public function build(ContentRepositoryServiceFactoryDependencies $serviceFactoryDependencies): ContentRepositoryServiceInterface
{
$this->eventStore = $serviceFactoryDependencies->eventStore;
$this->subscriptionEngine = $serviceFactoryDependencies->subscriptionEngine;
return new class implements ContentRepositoryServiceInterface
{
};
}
};
$this->getContentRepositoryService($eventStoreAndSubscriptionEngine);
$eventStoreAndSubscriptionEngine->eventStore->commit($streamName, Events::with($artificiallyConstructedEvent), ExpectedVersion::ANY());
$eventStoreAndSubscriptionEngine->subscriptionEngine->catchUpActive();
}

/**
Expand Down

0 comments on commit c393957

Please sign in to comment.