Skip to content

Commit

Permalink
TASK: Adjust to overhauled command constructors (#3612)
Browse files Browse the repository at this point in the history
* WIP: FEATURE: Adjust to overhauled command constructors

Related: #4375

* Adjust to overhauled command constructors 2/2
  • Loading branch information
bwaidelich authored Sep 14, 2023
1 parent 684bb2f commit 7a6c923
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 25 deletions.
11 changes: 3 additions & 8 deletions Classes/Controller/BackendServiceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -338,14 +338,9 @@ public function changeBaseWorkspaceAction(string $targetWorkspaceName, string $d
$currentAccount->getAccountIdentifier()
)->toContentRepositoryWorkspaceName();

$command = ChangeBaseWorkspace::create($userWorkspaceName, WorkspaceName::fromString($targetWorkspaceName));
try {
$contentRepository->handle(
new ChangeBaseWorkspace(
$userWorkspaceName,
WorkspaceName::fromString($targetWorkspaceName),
$newCOnt = ContentStreamId::create()
)
)->block();
$contentRepository->handle($command)->block();
} catch (WorkspaceIsNotEmptyException $exception) {
$error = new Error();
$error->setMessage('Your personal workspace currently contains unpublished changes.'
Expand All @@ -366,7 +361,7 @@ public function changeBaseWorkspaceAction(string $targetWorkspaceName, string $d

$subgraph = $contentRepository->getContentGraph()
->getSubgraph(
$newCOnt,
$command->newContentStreamId,
$nodeAddress->dimensionSpacePoint,
VisibilityConstraints::withoutRestrictions()
);
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Model/Changes/AbstractCreate.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ protected function createNode(

$nodeAggregateId = NodeAggregateId::create(); // generate a new NodeAggregateId

$command = new CreateNodeAggregateWithNode(
$command = CreateNodeAggregateWithNode::create(
$parentNode->subgraphIdentity->contentStreamId,
$nodeAggregateId,
$nodeTypeName,
Expand Down
4 changes: 2 additions & 2 deletions Classes/Domain/Model/Changes/MoveAfter.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ public function apply(): void
$hasEqualParentNode = $parentNode->nodeAggregateId
->equals($parentNodeOfPreviousSibling->nodeAggregateId);

$command = new MoveNodeAggregate(
$command = MoveNodeAggregate::create(
$subject->subgraphIdentity->contentStreamId,
$subject->subgraphIdentity->dimensionSpacePoint,
$subject->nodeAggregateId,
RelationDistributionStrategy::STRATEGY_GATHER_ALL,
$hasEqualParentNode ? null : $parentNodeOfPreviousSibling->nodeAggregateId,
$precedingSibling->nodeAggregateId,
$succeedingSibling?->nodeAggregateId,
RelationDistributionStrategy::STRATEGY_GATHER_ALL
);

$contentRepository = $this->contentRepositoryRegistry->get($subject->subgraphIdentity->contentRepositoryId);
Expand Down
4 changes: 2 additions & 2 deletions Classes/Domain/Model/Changes/MoveBefore.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,16 @@ public function apply(): void
$contentRepository = $this->contentRepositoryRegistry->get($subject->subgraphIdentity->contentRepositoryId);

$contentRepository->handle(
new MoveNodeAggregate(
MoveNodeAggregate::create(
$subject->subgraphIdentity->contentStreamId,
$subject->subgraphIdentity->dimensionSpacePoint,
$subject->nodeAggregateId,
RelationDistributionStrategy::STRATEGY_GATHER_ALL,
$hasEqualParentNode
? null
: $succeedingSiblingParent->nodeAggregateId,
$precedingSibling?->nodeAggregateId,
$succeedingSibling->nodeAggregateId,
RelationDistributionStrategy::STRATEGY_GATHER_ALL
)
)->block();

Expand Down
6 changes: 2 additions & 4 deletions Classes/Domain/Model/Changes/MoveInto.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,12 @@ public function apply(): void

$contentRepository = $this->contentRepositoryRegistry->get($subject->subgraphIdentity->contentRepositoryId);
$contentRepository->handle(
new MoveNodeAggregate(
MoveNodeAggregate::create(
$subject->subgraphIdentity->contentStreamId,
$subject->subgraphIdentity->dimensionSpacePoint,
$subject->nodeAggregateId,
RelationDistributionStrategy::STRATEGY_GATHER_ALL,
$hasEqualParentNode ? null : $parentNode->nodeAggregateId,
null,
null,
RelationDistributionStrategy::STRATEGY_GATHER_ALL
)
)->block();

Expand Down
10 changes: 5 additions & 5 deletions Classes/Domain/Model/Changes/Property.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public function apply(): void
$originDimensionSpacePoint = OriginDimensionSpacePoint::fromDimensionSpacePoint($subject->subgraphIdentity->dimensionSpacePoint);
// if origin dimension space point != current DSP -> translate transparently (matching old behavior)
$contentRepository->handle(
new CreateNodeVariant(
CreateNodeVariant::create(
$subject->subgraphIdentity->contentStreamId,
$subject->nodeAggregateId,
$subject->originDimensionSpacePoint,
Expand All @@ -200,7 +200,7 @@ public function apply(): void
)->block();
}
$commandResult = $contentRepository->handle(
new SetNodeProperties(
SetNodeProperties::create(
$subject->subgraphIdentity->contentStreamId,
$subject->nodeAggregateId,
$originDimensionSpacePoint,
Expand All @@ -215,7 +215,7 @@ public function apply(): void
// property starts with "_"
if ($propertyName === '_nodeType') {
$commandResult = $contentRepository->handle(
new ChangeNodeAggregateType(
ChangeNodeAggregateType::create(
$subject->subgraphIdentity->contentStreamId,
$subject->nodeAggregateId,
NodeTypeName::fromString($value),
Expand All @@ -225,7 +225,7 @@ public function apply(): void
} elseif ($propertyName === '_hidden') {
if ($value === true) {
$commandResult = $contentRepository->handle(
new DisableNodeAggregate(
DisableNodeAggregate::create(
$subject->subgraphIdentity->contentStreamId,
$subject->nodeAggregateId,
$subject->originDimensionSpacePoint->toDimensionSpacePoint(),
Expand All @@ -235,7 +235,7 @@ public function apply(): void
} else {
// unhide
$commandResult = $contentRepository->handle(
new EnableNodeAggregate(
EnableNodeAggregate::create(
$subject->subgraphIdentity->contentStreamId,
$subject->nodeAggregateId,
$subject->originDimensionSpacePoint->toDimensionSpacePoint(),
Expand Down
6 changes: 4 additions & 2 deletions Classes/Domain/Model/Changes/Remove.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,15 @@ public function apply(): void
$this->updateWorkspaceInfo();

$closestDocumentParentNode = $this->findClosestDocumentNode($subject);
$command = new RemoveNodeAggregate(
$command = RemoveNodeAggregate::create(
$subject->subgraphIdentity->contentStreamId,
$subject->nodeAggregateId,
$subject->subgraphIdentity->dimensionSpacePoint,
NodeVariantSelectionStrategy::STRATEGY_ALL_SPECIALIZATIONS,
$closestDocumentParentNode?->nodeAggregateId
);
if ($closestDocumentParentNode !== null) {
$command = $command->withRemovalAttachmentPoint($closestDocumentParentNode?->nodeAggregateId);
}

$contentRepository = $this->contentRepositoryRegistry->get($subject->subgraphIdentity->contentRepositoryId);
$contentRepository->handle($command)->block();
Expand Down
2 changes: 1 addition & 1 deletion Classes/Service/PublishingService.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function publishWorkspace(ContentRepository $contentRepository, Workspace
)->block();

$contentRepository->handle(
new PublishWorkspace(
PublishWorkspace::create(
$workspaceName
)
)->block();
Expand Down

0 comments on commit 7a6c923

Please sign in to comment.