|
13 | 13 | */
|
14 | 14 |
|
15 | 15 | use InvalidArgumentException;
|
| 16 | +use Neos\ContentRepository\Core\DimensionSpace\OriginDimensionSpacePoint; |
| 17 | +use Neos\ContentRepository\Core\Feature\NodeDuplication\Command\CopyNodesRecursively; |
16 | 18 | use Neos\ContentRepository\Core\Feature\NodeMove\Command\MoveNodeAggregate;
|
17 | 19 | use Neos\ContentRepository\Core\Feature\NodeMove\Dto\RelationDistributionStrategy;
|
18 |
| -use Neos\Neos\Ui\Domain\Model\Feedback\Operations\RemoveNode; |
| 20 | +use Neos\ContentRepository\Core\Feature\NodeRemoval\Command\RemoveNodeAggregate; |
| 21 | +use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints; |
| 22 | +use Neos\ContentRepository\Core\SharedModel\Node\NodeVariantSelectionStrategy; |
19 | 23 | use Neos\Neos\Ui\Domain\Model\Feedback\Operations\UpdateNodeInfo;
|
20 | 24 |
|
21 | 25 | /**
|
@@ -71,19 +75,49 @@ public function apply(): void
|
71 | 75 | $hasEqualParentNode = $parentNode->aggregateId
|
72 | 76 | ->equals($parentNodeOfPreviousSibling->aggregateId);
|
73 | 77 |
|
74 |
| - |
75 | 78 | $contentRepository = $this->contentRepositoryRegistry->get($subject->contentRepositoryId);
|
76 | 79 |
|
77 |
| - $command = MoveNodeAggregate::create( |
78 |
| - $subject->workspaceName, |
79 |
| - $subject->dimensionSpacePoint, |
80 |
| - $subject->aggregateId, |
81 |
| - RelationDistributionStrategy::STRATEGY_GATHER_ALL, |
82 |
| - $hasEqualParentNode ? null : $parentNodeOfPreviousSibling->aggregateId, |
83 |
| - $precedingSibling->aggregateId, |
84 |
| - $succeedingSibling?->aggregateId, |
85 |
| - ); |
86 |
| - $contentRepository->handle($command); |
| 80 | + if (!$precedingSibling->dimensionSpacePoint->equals($subject->dimensionSpacePoint)) { |
| 81 | + // WORKAROUND for MOVE ACROSS DIMENSIONS: |
| 82 | + // - we want it to work like a copy/paste, followed by an original delete. |
| 83 | + // - This is to ensure the user can use it as expected from text editors, where context |
| 84 | + // is not preserved during cut/paste. |
| 85 | + // - LATERON, we need to expose CreateNodeVariant (which creates connected variants) in the UI as well. |
| 86 | + $command = CopyNodesRecursively::createFromSubgraphAndStartNode( |
| 87 | + $contentRepository->getContentGraph($subject->workspaceName)->getSubgraph( |
| 88 | + $subject->dimensionSpacePoint, |
| 89 | + VisibilityConstraints::withoutRestrictions() |
| 90 | + ), |
| 91 | + $subject->workspaceName, |
| 92 | + $subject, |
| 93 | + // NOTE: in order to be able to copy/paste across dimensions, we need to use |
| 94 | + // the TARGET NODE's DimensionSpacePoint to create the node in the target dimension. |
| 95 | + OriginDimensionSpacePoint::fromDimensionSpacePoint($precedingSibling->dimensionSpacePoint), |
| 96 | + $parentNodeOfPreviousSibling->aggregateId, |
| 97 | + $succeedingSibling?->aggregateId |
| 98 | + ); |
| 99 | + |
| 100 | + $contentRepository->handle($command); |
| 101 | + |
| 102 | + $command = RemoveNodeAggregate::create( |
| 103 | + $subject->workspaceName, |
| 104 | + $subject->aggregateId, |
| 105 | + $subject->dimensionSpacePoint, |
| 106 | + NodeVariantSelectionStrategy::STRATEGY_ALL_SPECIALIZATIONS, |
| 107 | + ); |
| 108 | + $contentRepository->handle($command); |
| 109 | + } else { |
| 110 | + $command = MoveNodeAggregate::create( |
| 111 | + $subject->workspaceName, |
| 112 | + $subject->dimensionSpacePoint, |
| 113 | + $subject->aggregateId, |
| 114 | + RelationDistributionStrategy::STRATEGY_GATHER_ALL, |
| 115 | + $hasEqualParentNode ? null : $parentNodeOfPreviousSibling->aggregateId, |
| 116 | + $precedingSibling->aggregateId, |
| 117 | + $succeedingSibling?->aggregateId, |
| 118 | + ); |
| 119 | + $contentRepository->handle($command); |
| 120 | + } |
87 | 121 |
|
88 | 122 | $updateParentNodeInfo = new UpdateNodeInfo();
|
89 | 123 | $updateParentNodeInfo->setNode($parentNodeOfPreviousSibling);
|
|
0 commit comments