diff --git a/Neos.ContentRepository.Core/Classes/EventStore/EventNormalizer.php b/Neos.ContentRepository.Core/Classes/EventStore/EventNormalizer.php index 52f23d63910..6a7ca968917 100644 --- a/Neos.ContentRepository.Core/Classes/EventStore/EventNormalizer.php +++ b/Neos.ContentRepository.Core/Classes/EventStore/EventNormalizer.php @@ -162,13 +162,7 @@ public function denormalize(Event $event): EventInterface throw new \RuntimeException(sprintf('Expected array got %s', $eventDataAsArray)); } /** {@see EventInterface::fromArray()} */ - $eventInstance = $eventClassName::fromArray($eventDataAsArray); - return match ($eventInstance::class) { - // upcast disabled / enabled events to the corresponding SubtreeTag events - NodeAggregateWasDisabled::class => new SubtreeWasTagged($eventInstance->workspaceName, $eventInstance->contentStreamId, $eventInstance->nodeAggregateId, $eventInstance->affectedDimensionSpacePoints, SubtreeTag::disabled()), - NodeAggregateWasEnabled::class => new SubtreeWasUntagged($eventInstance->workspaceName, $eventInstance->contentStreamId, $eventInstance->nodeAggregateId, $eventInstance->affectedDimensionSpacePoints, SubtreeTag::disabled()), - default => $eventInstance, - }; + return $eventClassName::fromArray($eventDataAsArray); } private function getEventData(EventInterface $event): EventData diff --git a/Neos.ContentRepository.Core/Classes/Feature/NodeDisabling/Event/NodeAggregateWasDisabled.php b/Neos.ContentRepository.Core/Classes/Feature/NodeDisabling/Event/NodeAggregateWasDisabled.php index e65d6ce7055..5a9c93ad5f2 100644 --- a/Neos.ContentRepository.Core/Classes/Feature/NodeDisabling/Event/NodeAggregateWasDisabled.php +++ b/Neos.ContentRepository.Core/Classes/Feature/NodeDisabling/Event/NodeAggregateWasDisabled.php @@ -16,74 +16,36 @@ use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePointSet; use Neos\ContentRepository\Core\EventStore\EventInterface; -use Neos\ContentRepository\Core\Feature\Common\EmbedsContentStreamId; -use Neos\ContentRepository\Core\Feature\Common\EmbedsNodeAggregateId; -use Neos\ContentRepository\Core\Feature\Common\EmbedsWorkspaceName; -use Neos\ContentRepository\Core\Feature\Common\PublishableToWorkspaceInterface; +use Neos\ContentRepository\Core\Feature\SubtreeTagging\Dto\SubtreeTag; use Neos\ContentRepository\Core\Feature\SubtreeTagging\Event\SubtreeWasTagged; use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId; use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId; use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName; /** - * A node aggregate was disabled - * - * @deprecated This event will never be emitted, it is up-casted to a corresponding {@see SubtreeWasTagged} event instead in the {@see EventNormalizer}. This implementation is just kept for backwards-compatibility + * @deprecated This event will never be emitted, it is up-casted to a corresponding {@see SubtreeWasTagged} event instead. This implementation is just kept for backwards-compatibility * @internal */ -final readonly class NodeAggregateWasDisabled implements - EventInterface, - PublishableToWorkspaceInterface, - EmbedsContentStreamId, - EmbedsNodeAggregateId, - EmbedsWorkspaceName +final readonly class NodeAggregateWasDisabled implements EventInterface { - public function __construct( - public WorkspaceName $workspaceName, - public ContentStreamId $contentStreamId, - public NodeAggregateId $nodeAggregateId, - /** The dimension space points the node aggregate was disabled in */ - public DimensionSpacePointSet $affectedDimensionSpacePoints, - ) { - } - - public function getContentStreamId(): ContentStreamId + private function __construct() { - return $this->contentStreamId; - } - - public function getNodeAggregateId(): NodeAggregateId - { - return $this->nodeAggregateId; - } - - public function getWorkspaceName(): WorkspaceName - { - return $this->workspaceName; - } - - public function withWorkspaceNameAndContentStreamId(WorkspaceName $targetWorkspaceName, ContentStreamId $contentStreamId): self - { - return new self( - $targetWorkspaceName, - $contentStreamId, - $this->nodeAggregateId, - $this->affectedDimensionSpacePoints, - ); + // legacy event must not be instantiated } public static function fromArray(array $values): EventInterface { - return new self( + return new SubtreeWasTagged( WorkspaceName::fromString($values['workspaceName']), ContentStreamId::fromString($values['contentStreamId']), NodeAggregateId::fromString($values['nodeAggregateId']), DimensionSpacePointSet::fromArray($values['affectedDimensionSpacePoints']), + SubtreeTag::disabled() ); } public function jsonSerialize(): array { - return get_object_vars($this); + throw new \RuntimeException('Legacy event instance must not exist.'); } } diff --git a/Neos.ContentRepository.Core/Classes/Feature/NodeDisabling/Event/NodeAggregateWasEnabled.php b/Neos.ContentRepository.Core/Classes/Feature/NodeDisabling/Event/NodeAggregateWasEnabled.php index f863fd97a8a..accc0d0317d 100644 --- a/Neos.ContentRepository.Core/Classes/Feature/NodeDisabling/Event/NodeAggregateWasEnabled.php +++ b/Neos.ContentRepository.Core/Classes/Feature/NodeDisabling/Event/NodeAggregateWasEnabled.php @@ -16,74 +16,36 @@ use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePointSet; use Neos\ContentRepository\Core\EventStore\EventInterface; -use Neos\ContentRepository\Core\EventStore\EventNormalizer; -use Neos\ContentRepository\Core\Feature\Common\EmbedsContentStreamId; -use Neos\ContentRepository\Core\Feature\Common\EmbedsNodeAggregateId; -use Neos\ContentRepository\Core\Feature\Common\EmbedsWorkspaceName; -use Neos\ContentRepository\Core\Feature\Common\PublishableToWorkspaceInterface; +use Neos\ContentRepository\Core\Feature\SubtreeTagging\Dto\SubtreeTag; use Neos\ContentRepository\Core\Feature\SubtreeTagging\Event\SubtreeWasUntagged; use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId; use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId; use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName; /** - * A node aggregate was enabled - * - * @deprecated This event will never be emitted, it is up-casted to a corresponding {@see SubtreeWasUntagged} event instead in the {@see EventNormalizer}. This implementation is just kept for backwards-compatibility + * @deprecated This event will never be emitted, it is up-casted to a corresponding {@see SubtreeWasUntagged} event instead. This implementation is just kept for backwards-compatibility * @internal */ -final readonly class NodeAggregateWasEnabled implements - EventInterface, - PublishableToWorkspaceInterface, - EmbedsContentStreamId, - EmbedsNodeAggregateId, - EmbedsWorkspaceName +final readonly class NodeAggregateWasEnabled implements EventInterface { - public function __construct( - public WorkspaceName $workspaceName, - public ContentStreamId $contentStreamId, - public NodeAggregateId $nodeAggregateId, - public DimensionSpacePointSet $affectedDimensionSpacePoints, - ) { - } - - public function getContentStreamId(): ContentStreamId + private function __construct() { - return $this->contentStreamId; - } - - public function getNodeAggregateId(): NodeAggregateId - { - return $this->nodeAggregateId; - } - - public function getWorkspaceName(): WorkspaceName - { - return $this->workspaceName; - } - - public function withWorkspaceNameAndContentStreamId(WorkspaceName $targetWorkspaceName, ContentStreamId $contentStreamId): self - { - return new self( - $targetWorkspaceName, - $contentStreamId, - $this->nodeAggregateId, - $this->affectedDimensionSpacePoints, - ); + // legacy event must not be instantiated } public static function fromArray(array $values): EventInterface { - return new self( + return new SubtreeWasUntagged( WorkspaceName::fromString($values['workspaceName']), ContentStreamId::fromString($values['contentStreamId']), NodeAggregateId::fromString($values['nodeAggregateId']), DimensionSpacePointSet::fromArray($values['affectedDimensionSpacePoints']), + SubtreeTag::disabled() ); } public function jsonSerialize(): array { - return get_object_vars($this); + throw new \RuntimeException('Legacy event instance must not exist.'); } }