diff --git a/Classes/Domain/Model/Changes/MoveAfter.php b/Classes/Domain/Model/Changes/MoveAfter.php index 420644702c..fadb9bc50d 100644 --- a/Classes/Domain/Model/Changes/MoveAfter.php +++ b/Classes/Domain/Model/Changes/MoveAfter.php @@ -71,16 +71,20 @@ public function apply(): void $hasEqualParentNode = $parentNode->aggregateId ->equals($parentNodeOfPreviousSibling->aggregateId); - $contentRepository = $this->contentRepositoryRegistry->get($subject->contentRepositoryId); - $nodeType = $contentRepository->getNodeTypeManager()->getNodeType($this->subject->nodeTypeName); - $strategy = $nodeType->getConfiguration('options.moveNodeStrategy') ?: throw new \RuntimeException('Nodetype is missing required option "moveNodeStrategy".', 1645577794); - $strategy = RelationDistributionStrategy::tryFrom($strategy) ?? throw new \RuntimeException('Nodetype has an invalid configuration for option "moveNodeStrategy".', 1645577794);; + $rawMoveNodeStrategy = $this->getNodeType($this->subject)?->getConfiguration('options.moveNodeStrategy'); + if (!is_string($rawMoveNodeStrategy)) { + throw new \RuntimeException(sprintf('NodeType "%s" has an invalid configuration for option "moveNodeStrategy" expected string got %s', $this->subject->nodeTypeName->value, get_debug_type($rawMoveNodeStrategy)), 1732010016); + } + $moveNodeStrategy = RelationDistributionStrategy::tryFrom($rawMoveNodeStrategy); + if ($moveNodeStrategy === null) { + throw new \RuntimeException(sprintf('NodeType "%s" has an invalid configuration for option "moveNodeStrategy" got %s', $this->subject->nodeTypeName->value, $rawMoveNodeStrategy), 1732010011); + } $command = MoveNodeAggregate::create( $subject->workspaceName, $subject->dimensionSpacePoint, $subject->aggregateId, - $strategy, + $moveNodeStrategy, $hasEqualParentNode ? null : $parentNodeOfPreviousSibling->aggregateId, $precedingSibling->aggregateId, $succeedingSibling?->aggregateId, diff --git a/Classes/Domain/Model/Changes/MoveBefore.php b/Classes/Domain/Model/Changes/MoveBefore.php index 0a57fa693e..d71d2c7566 100644 --- a/Classes/Domain/Model/Changes/MoveBefore.php +++ b/Classes/Domain/Model/Changes/MoveBefore.php @@ -68,15 +68,20 @@ public function apply(): void ->equals($succeedingSiblingParent->aggregateId); $contentRepository = $this->contentRepositoryRegistry->get($subject->contentRepositoryId); - $nodeType = $contentRepository->getNodeTypeManager()->getNodeType($this->subject->nodeTypeName); - $strategy = $nodeType->getConfiguration('options.moveNodeStrategy') ?: throw new \RuntimeException('Nodetype is missing required option "moveNodeStrategy".', 1645577794); - $strategy = RelationDistributionStrategy::tryFrom($strategy) ?? throw new \RuntimeException('Nodetype has an invalid configuration for option "moveNodeStrategy".', 1645577794); + $rawMoveNodeStrategy = $this->getNodeType($this->subject)?->getConfiguration('options.moveNodeStrategy'); + if (!is_string($rawMoveNodeStrategy)) { + throw new \RuntimeException(sprintf('NodeType "%s" has an invalid configuration for option "moveNodeStrategy" expected string got %s', $this->subject->nodeTypeName->value, get_debug_type($rawMoveNodeStrategy)), 1732010016); + } + $moveNodeStrategy = RelationDistributionStrategy::tryFrom($rawMoveNodeStrategy); + if ($moveNodeStrategy === null) { + throw new \RuntimeException(sprintf('NodeType "%s" has an invalid configuration for option "moveNodeStrategy" got %s', $this->subject->nodeTypeName->value, $rawMoveNodeStrategy), 1732010011); + } $contentRepository->handle( MoveNodeAggregate::create( $subject->workspaceName, $subject->dimensionSpacePoint, $subject->aggregateId, - $strategy, + $moveNodeStrategy, $hasEqualParentNode ? null : $succeedingSiblingParent->aggregateId, diff --git a/Classes/Domain/Model/Changes/MoveInto.php b/Classes/Domain/Model/Changes/MoveInto.php index fe2757751a..95dad1c83e 100644 --- a/Classes/Domain/Model/Changes/MoveInto.php +++ b/Classes/Domain/Model/Changes/MoveInto.php @@ -78,15 +78,20 @@ public function apply(): void ->equals($parentNode->aggregateId); $contentRepository = $this->contentRepositoryRegistry->get($subject->contentRepositoryId); - $nodeType = $contentRepository->getNodeTypeManager()->getNodeType($this->subject->nodeTypeName); - $strategy = $nodeType->getConfiguration('options.moveNodeStrategy') ?: throw new \RuntimeException('Nodetype is missing required option "moveNodeStrategy".', 1645577794); - $strategy = RelationDistributionStrategy::tryFrom($strategy) ?? throw new \RuntimeException('Nodetype has an invalid configuration for option "moveNodeStrategy".', 1645577794); + $rawMoveNodeStrategy = $this->getNodeType($this->subject)?->getConfiguration('options.moveNodeStrategy'); + if (!is_string($rawMoveNodeStrategy)) { + throw new \RuntimeException(sprintf('NodeType "%s" has an invalid configuration for option "moveNodeStrategy" expected string got %s', $this->subject->nodeTypeName->value, get_debug_type($rawMoveNodeStrategy)), 1732010016); + } + $moveNodeStrategy = RelationDistributionStrategy::tryFrom($rawMoveNodeStrategy); + if ($moveNodeStrategy === null) { + throw new \RuntimeException(sprintf('NodeType "%s" has an invalid configuration for option "moveNodeStrategy" got %s', $this->subject->nodeTypeName->value, $rawMoveNodeStrategy), 1732010011); + } $contentRepository->handle( MoveNodeAggregate::create( $subject->workspaceName, $subject->dimensionSpacePoint, $subject->aggregateId, - $strategy, + $moveNodeStrategy, $hasEqualParentNode ? null : $parentNode->aggregateId, ) );