Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TASK: Command constructor followup to #4489 #4646

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ final class SetNodeReferences implements CommandInterface
* @param ReferenceName $referenceName Name of the reference to set
* @param NodeReferencesToWrite $references Unserialized reference(s) to set
*/
public function __construct(
private function __construct(
public readonly ContentStreamId $contentStreamId,
public readonly NodeAggregateId $sourceNodeAggregateId,
public readonly OriginDimensionSpacePoint $sourceOriginDimensionSpacePoint,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,31 +33,27 @@ final class RemoveNodeAggregate implements
MatchableWithNodeIdToPublishOrDiscardInterface
{
/**
* @param ContentStreamId $contentStreamId
* @param ContentStreamId $contentStreamId The content stream in which the remove operation is to be performed
* @param NodeAggregateId $nodeAggregateId The identifier of the node aggregate to remove
* @param DimensionSpacePoint $coveredDimensionSpacePoint One of the dimension space points covered by the node aggregate in which the user intends to remove it
* @param NodeVariantSelectionStrategy $nodeVariantSelectionStrategy The strategy the user chose to determine which specialization variants will also be removed
* @param NodeAggregateId|null $removalAttachmentPoint Internal. It stores the document node id of the removed node, as that is what the UI needs later on for the change display. {@see self::withRemovalAttachmentPoint()}
*/
public function __construct(
private function __construct(
public readonly ContentStreamId $contentStreamId,
public readonly NodeAggregateId $nodeAggregateId,
/** One of the dimension space points covered by the node aggregate in which the user intends to remove it */
public readonly DimensionSpacePoint $coveredDimensionSpacePoint,
public readonly NodeVariantSelectionStrategy $nodeVariantSelectionStrategy,
/**
* This is usually the NodeAggregateId of the parent node of the deleted node. It is needed for instance
* in the Neos UI for the following scenario:
* - when removing a node, you still need to be able to publish the removal.
* - For this to work, the Neos UI needs to know the id of the removed Node, **on the page
* where the removal happened** (so that the user can decide to publish a single page INCLUDING the removal
* on the page)
* - Because this command will *remove* the edge,
* we cannot know the position in the tree after doing the removal anymore.
*
* That's why we need this field: For the Neos UI, it stores the document node of the removed node
* (see Remove.php), as that is what the UI needs lateron for the change display.
*/
public readonly ?NodeAggregateId $removalAttachmentPoint
) {
}

/**
* @param ContentStreamId $contentStreamId The content stream in which the remove operation is to be performed
* @param NodeAggregateId $nodeAggregateId The identifier of the node aggregate to remove
* @param DimensionSpacePoint $coveredDimensionSpacePoint One of the dimension space points covered by the node aggregate in which the user intends to remove it
* @param NodeVariantSelectionStrategy $nodeVariantSelectionStrategy The strategy the user chose to determine which specialization variants will also be removed
*/
public static function create(ContentStreamId $contentStreamId, NodeAggregateId $nodeAggregateId, DimensionSpacePoint $coveredDimensionSpacePoint, NodeVariantSelectionStrategy $nodeVariantSelectionStrategy): self
{
return new self($contentStreamId, $nodeAggregateId, $coveredDimensionSpacePoint, $nodeVariantSelectionStrategy, null);
Expand All @@ -80,6 +76,14 @@ public static function fromArray(array $array): self
}

/**
* This adds usually the NodeAggregateId of the parent document node of the deleted node.
* It is needed for instance in the Neos UI for the following scenario:
* - when removing a node, you still need to be able to publish the removal.
* - For this to work, the Neos UI needs to know the id of the removed Node, **on the page where the removal happened**
* (so that the user can decide to publish a single page INCLUDING the removal on the page)
* - Because this command will *remove* the edge,
* we cannot know the position in the tree after doing the removal anymore.
*
* @param NodeAggregateId $removalAttachmentPoint
* @internal
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,13 @@ final class PublishIndividualNodesFromWorkspace implements CommandInterface
/**
* @param WorkspaceName $workspaceName Name of the affected workspace
* @param NodeIdsToPublishOrDiscard $nodesToPublish Ids of the nodes to publish or discard
* @param ContentStreamId $contentStreamIdForMatchingPart The id of the new content stream that will contain all events to be published
* @param ContentStreamId $contentStreamIdForRemainingPart The id of the new content stream that will contain all remaining events
* @param ContentStreamId $contentStreamIdForMatchingPart The id of the new content stream that will contain all events to be published {@see self::withContentStreamIdForMatchingPart()}
* @param ContentStreamId $contentStreamIdForRemainingPart The id of the new content stream that will contain all remaining events {@see self::withContentStreamIdForRemainingPart()}
*/
private function __construct(
public readonly WorkspaceName $workspaceName,
public readonly NodeIdsToPublishOrDiscard $nodesToPublish,
/**
* during the publish process, we sort the events so that the events we want to publish
* come first. In this process, two new content streams are generated:
* - the first one contains all events which we want to publish
* - the second one is based on the first one, and contains all the remaining events (which we want to keep
* in the user workspace).
*
* This property contains the ID of the first content stream, so that this command
* can run fully deterministic - we need this for the test cases.
*/
public readonly ContentStreamId $contentStreamIdForMatchingPart,
/**
* See the description of {@see $contentStreamIdForMatchingPart}.
*
* This property contains the ID of the second content stream, so that this command
* can run fully deterministic - we need this for the test cases.
*/
public readonly ContentStreamId $contentStreamIdForRemainingPart
) {
}
Expand All @@ -70,11 +54,27 @@ public static function create(WorkspaceName $workspaceName, NodeIdsToPublishOrDi
);
}

/**
* During the publish process, we sort the events so that the events we want to publish
* come first. In this process, two new content streams are generated:
* - the first one contains all events which we want to publish
* - the second one is based on the first one, and contains all the remaining events (which we want to keep
* in the user workspace).
*
* This method adds the ID of the first content stream, so that the command
* can run fully deterministic - we need this for the test cases.
*/
public function withContentStreamIdForMatchingPart(ContentStreamId $contentStreamIdForMatchingPart): self
{
return new self($this->workspaceName, $this->nodesToPublish, $contentStreamIdForMatchingPart, $this->contentStreamIdForRemainingPart);
}

/**
* See the description of {@see self::withContentStreamIdForMatchingPart()}.
*
* This property adds the ID of the second content stream, so that the command
* can run fully deterministic - we need this for the test cases.
*/
public function withContentStreamIdForRemainingPart(ContentStreamId $contentStreamIdForRemainingPart): self
{
return new self($this->workspaceName, $this->nodesToPublish, $this->contentStreamIdForMatchingPart, $contentStreamIdForRemainingPart);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function theCommandSetNodeReferencesIsExecutedWithPayload(TableNode $payl
)
);

$command = new SetNodeReferences(
$command = SetNodeReferences::create(
$contentStreamId,
NodeAggregateId::fromString($commandArguments['sourceNodeAggregateId']),
$sourceOriginDimensionSpacePoint,
Expand Down
Loading