Skip to content

Commit

Permalink
TASK: Adjust to WorkspaceName in getSubgraph (more complex usages)
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsdesign committed Mar 19, 2024
1 parent 53a1687 commit e37a4b8
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ private function handleMoveDimensionSpacePoint(
$streamName = ContentStreamEventStreamName::fromContentStreamId($command->contentStreamId)
->getEventStreamName();

// todo use WorkspaceName here as well but the command doesnt expose it
// https://github.com/neos/neos-development-collection/issues/4942
self::requireDimensionSpacePointToBeEmptyInContentStream(
$command->target,
$command->contentStreamId,
Expand Down Expand Up @@ -99,6 +101,8 @@ private function handleAddDimensionShineThrough(
$streamName = ContentStreamEventStreamName::fromContentStreamId($command->contentStreamId)
->getEventStreamName();

// todo use WorkspaceName here as well but the command doesnt expose it
// https://github.com/neos/neos-development-collection/issues/4942
self::requireDimensionSpacePointToBeEmptyInContentStream(
$command->target,
$command->contentStreamId,
Expand Down Expand Up @@ -134,18 +138,18 @@ protected function requireDimensionSpacePointToExistInConfiguration(DimensionSpa

private static function requireDimensionSpacePointToBeEmptyInContentStream(
DimensionSpacePoint $dimensionSpacePoint,
ContentStreamId $contentStreamId,
WorkspaceName $workspaceName,
ContentGraphInterface $contentGraph
): void {
$subgraph = $contentGraph->getSubgraph(
$contentStreamId,
$workspaceName,
$dimensionSpacePoint,
VisibilityConstraints::withoutRestrictions()
);
if ($subgraph->countNodes() > 0) {
throw new DimensionSpacePointAlreadyExists(sprintf(
'the content stream %s already contained nodes in dimension space point %s - this is not allowed.',
$contentStreamId->value,
'the workspace %s already contained nodes in dimension space point %s - this is not allowed.',
$workspaceName->value,
$dimensionSpacePoint->toJson(),
), 1612898126);
}
Expand Down
22 changes: 12 additions & 10 deletions Neos.ContentRepository.Core/Classes/Feature/NodeMove/NodeMove.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
use Neos\ContentRepository\Core\SharedModel\Exception\NodeAggregatesTypeIsAmbiguous;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;

/**
* @internal implementation detail of Command Handlers
Expand Down Expand Up @@ -149,7 +150,8 @@ private function handleMoveNodeAggregate(
$originNodeMoveMappings[] = new OriginNodeMoveMapping(
$movedNodeOrigin,
$this->resolveCoverageNodeMoveMappings(
$contentStreamId,
// todo UNSAFE as override via ContentStreamIdOverride will NOT be taken into account!!!
$command->workspaceName,
$nodeAggregate,
$command->newParentNodeAggregateId,
$command->newPrecedingSiblingNodeAggregateId,
Expand Down Expand Up @@ -188,18 +190,18 @@ private function handleMoveNodeAggregate(
*
* If no parent node aggregate is defined, it will be resolved from the already evaluated new succeeding siblings.
*
* @todo move to content graph for more efficient calculation, if possible
* @todo move to content graph for more efficient calculation, if possible !!!
*/
private function resolveNewParentAssignments(
/** The content stream the move operation is performed in */
ContentStreamId $contentStreamId,
/** The workspace the move operation is performed in */
WorkspaceName $workspaceName,
/** The parent node aggregate's id*/
NodeAggregateId $parentId,
DimensionSpace\DimensionSpacePoint $coveredDimensionSpacePoint,
ContentRepository $contentRepository
): CoverageNodeMoveMapping {
$contentSubgraph = $contentRepository->getContentGraph()->getSubgraph(
$contentStreamId,
$workspaceName,
$coveredDimensionSpacePoint,
VisibilityConstraints::withoutRestrictions()
);
Expand Down Expand Up @@ -328,8 +330,8 @@ private function resolveSucceedingSiblingFromOriginSiblings(
}

private function resolveCoverageNodeMoveMappings(
/** The content stream the move operation is performed in */
ContentStreamId $contentStreamId,
/** The workspace the move operation is performed in */
WorkspaceName $workspaceName,
/** The node aggregate to be moved */
NodeAggregate $nodeAggregate,
/** The parent node aggregate id, has precedence over siblings when in doubt */
Expand All @@ -349,7 +351,7 @@ private function resolveCoverageNodeMoveMappings(

$visibilityConstraints = VisibilityConstraints::withoutRestrictions();
$originContentSubgraph = $contentRepository->getContentGraph()->getSubgraph(
$contentStreamId,
$workspaceName,
$originDimensionSpacePoint->toDimensionSpacePoint(),
$visibilityConstraints
);
Expand All @@ -358,7 +360,7 @@ private function resolveCoverageNodeMoveMappings(
->getIntersection($affectedDimensionSpacePoints) as $dimensionSpacePoint
) {
$contentSubgraph = $contentRepository->getContentGraph()->getSubgraph(
$contentStreamId,
$workspaceName,
$dimensionSpacePoint,
$visibilityConstraints
);
Expand Down Expand Up @@ -426,7 +428,7 @@ private function resolveCoverageNodeMoveMappings(
}
}
$coverageNodeMoveMappings[] = $this->resolveNewParentAssignments(
$contentStreamId,
$workspaceName,
$parentId,
$dimensionSpacePoint,
$contentRepository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Neos\ContentRepository\Core\NodeType\NodeTypeName;
use Neos\ContentRepository\Core\Projection\ContentGraph\NodeAggregate;
use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
use Neos\EventStore\Model\EventStream\ExpectedVersion;

class DisallowedChildNodeAdjustment
Expand Down Expand Up @@ -52,7 +53,7 @@ public function findAdjustmentsForNodeType(NodeTypeName $nodeTypeName): \Generat
// Then, we only want to remove the single edge.
foreach ($nodeAggregate->coveredDimensionSpacePoints as $coveredDimensionSpacePoint) {
$subgraph = $this->contentRepository->getContentGraph()->getSubgraph(
$nodeAggregate->contentStreamId,
WorkspaceName::forLive(), // structure adjustments are only carried out live
$coveredDimensionSpacePoint,
VisibilityConstraints::withoutRestrictions()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId;
use Neos\ContentRepository\Core\SharedModel\Node\NodeName;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
use Neos\EventStore\Model\EventStream\ExpectedVersion;

class TetheredNodeAdjustments
Expand Down Expand Up @@ -70,7 +71,7 @@ public function findAdjustmentsForNodeType(NodeTypeName $nodeTypeName): \Generat
$tetheredNodeName = NodeName::fromString($tetheredNodeName);

$subgraph = $this->contentRepository->getContentGraph()->getSubgraph(
$nodeAggregate->contentStreamId,
WorkspaceName::forLive(), // structure adjustments are only carried out live
$originDimensionSpacePoint->toDimensionSpacePoint(),
VisibilityConstraints::withoutRestrictions()
);
Expand Down Expand Up @@ -138,8 +139,7 @@ function () use ($tetheredNodeAggregate) {
if ($foundMissingOrDisallowedTetheredNodes === false) {
foreach ($originDimensionSpacePoints as $originDimensionSpacePoint) {
$subgraph = $this->contentRepository->getContentGraph()->getSubgraph(
// todo add workspace to node aggregate
$nodeAggregate->contentStreamId,
WorkspaceName::forLive(), // structure adjustments are only carried out live
$originDimensionSpacePoint->toDimensionSpacePoint(),
VisibilityConstraints::withoutRestrictions()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public function visibilityConstraintsAreSetTo(string $restrictionType): void
public function getCurrentSubgraph(): ContentSubgraphInterface
{
return $this->currentContentRepository->getContentGraph()->getSubgraph(
$this->currentContentStreamId,
$this->currentWorkspaceName,
$this->currentDimensionSpacePoint,
$this->currentVisibilityConstraints
);
Expand Down

0 comments on commit e37a4b8

Please sign in to comment.