Skip to content

Commit

Permalink
TASK: Add withSucceedingSiblingNodeAggregateId to remove parameter …
Browse files Browse the repository at this point in the history
…from main factory
  • Loading branch information
mhsdesign committed Jun 30, 2024
1 parent 89fea05 commit 30e35d5
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public function getContentDimensionsOrderedByPriority(): array
NodeTypeName::fromString('Neos.ContentRepository.Testing:Document'),
$origin,
NodeAggregateId::fromString('lady-eleonode-rootford'),
initialPropertyValues: PropertyValuesToWrite::fromArray([
PropertyValuesToWrite::fromArray([
'title' => 'title'
])
));
Expand All @@ -139,7 +139,7 @@ public function getContentDimensionsOrderedByPriority(): array
NodeTypeName::fromString('Neos.ContentRepository.Testing:Document'),
$origin,
NodeAggregateId::fromString('lady-eleonode-rootford'),
initialPropertyValues: PropertyValuesToWrite::fromArray([
PropertyValuesToWrite::fromArray([
'title' => 'title'
])
));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,11 @@ private function __construct(
* @param NodeTypeName $nodeTypeName Name of the node type of the new node
* @param OriginDimensionSpacePoint $originDimensionSpacePoint Origin of the new node in the dimension space. Will also be used to calculate a set of dimension points where the new node will cover from the configured specializations.
* @param NodeAggregateId $parentNodeAggregateId The id of the node aggregate underneath which the new node is added
* @param NodeAggregateId|null $succeedingSiblingNodeAggregateId Node aggregate id of the node's succeeding sibling (optional). If not given, the node will be added as the parent's first child
* @param PropertyValuesToWrite|null $initialPropertyValues The node's initial property values. Will be merged over the node type's default property values
*/
public static function create(WorkspaceName $workspaceName, NodeAggregateId $nodeAggregateId, NodeTypeName $nodeTypeName, OriginDimensionSpacePoint $originDimensionSpacePoint, NodeAggregateId $parentNodeAggregateId, ?NodeAggregateId $succeedingSiblingNodeAggregateId = null, ?PropertyValuesToWrite $initialPropertyValues = null): self
public static function create(WorkspaceName $workspaceName, NodeAggregateId $nodeAggregateId, NodeTypeName $nodeTypeName, OriginDimensionSpacePoint $originDimensionSpacePoint, NodeAggregateId $parentNodeAggregateId, ?PropertyValuesToWrite $initialPropertyValues = null): self
{
return new self($workspaceName, $nodeAggregateId, $nodeTypeName, $originDimensionSpacePoint, $parentNodeAggregateId, $initialPropertyValues ?: PropertyValuesToWrite::createEmpty(), $succeedingSiblingNodeAggregateId, null, NodeAggregateIdsByNodePaths::createEmpty());
return new self($workspaceName, $nodeAggregateId, $nodeTypeName, $originDimensionSpacePoint, $parentNodeAggregateId, $initialPropertyValues ?: PropertyValuesToWrite::createEmpty(), null, null, NodeAggregateIdsByNodePaths::createEmpty());
}

public function withInitialPropertyValues(PropertyValuesToWrite $newInitialPropertyValues): self
Expand Down Expand Up @@ -130,6 +129,25 @@ public function withTetheredDescendantNodeAggregateIds(NodeAggregateIdsByNodePat
);
}

/**
* Node aggregate id of the node's succeeding sibling (optional).
* If not given, the node will be added as the parent's first child
*/
public function withSucceedingSiblingNodeAggregateId(NodeAggregateId $succeedingSiblingNodeAggregateId): self
{
return new self(
$this->workspaceName,
$this->nodeAggregateId,
$this->nodeTypeName,
$this->originDimensionSpacePoint,
$this->parentNodeAggregateId,
$this->initialPropertyValues,
$succeedingSiblingNodeAggregateId,
$this->nodeName,
$this->tetheredDescendantNodeAggregateIds,
);
}

/**
* The node's optional name.
* Set if there is a meaningful relation to its parent that should be named.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,11 @@ private function __construct(
* @param NodeTypeName $nodeTypeName Name of the node type of the new node
* @param OriginDimensionSpacePoint $originDimensionSpacePoint Origin of the new node in the dimension space. Will also be used to calculate a set of dimension points where the new node will cover from the configured specializations.
* @param NodeAggregateId $parentNodeAggregateId The id of the node aggregate underneath which the new node is added
* @param NodeAggregateId|null $succeedingSiblingNodeAggregateId Node aggregate id of the node's succeeding sibling (optional). If not given, the node will be added as the parent's first child
* @param SerializedPropertyValues|null $initialPropertyValues The node's initial property values (serialized). Will be merged over the node type's default property values
*/
public static function create(WorkspaceName $workspaceName, NodeAggregateId $nodeAggregateId, NodeTypeName $nodeTypeName, OriginDimensionSpacePoint $originDimensionSpacePoint, NodeAggregateId $parentNodeAggregateId, NodeAggregateId $succeedingSiblingNodeAggregateId = null, SerializedPropertyValues $initialPropertyValues = null): self
public static function create(WorkspaceName $workspaceName, NodeAggregateId $nodeAggregateId, NodeTypeName $nodeTypeName, OriginDimensionSpacePoint $originDimensionSpacePoint, NodeAggregateId $parentNodeAggregateId, SerializedPropertyValues $initialPropertyValues = null): self
{
return new self($workspaceName, $nodeAggregateId, $nodeTypeName, $originDimensionSpacePoint, $parentNodeAggregateId, $initialPropertyValues ?? SerializedPropertyValues::createEmpty(), $succeedingSiblingNodeAggregateId, null, NodeAggregateIdsByNodePaths::createEmpty());
return new self($workspaceName, $nodeAggregateId, $nodeTypeName, $originDimensionSpacePoint, $parentNodeAggregateId, $initialPropertyValues ?? SerializedPropertyValues::createEmpty(), null, null, NodeAggregateIdsByNodePaths::createEmpty());
}

/**
Expand Down Expand Up @@ -139,6 +138,25 @@ public function withTetheredDescendantNodeAggregateIds(
);
}

/**
* Node aggregate id of the node's succeeding sibling (optional).
* If not given, the node will be added as the parent's first child
*/
public function withSucceedingSiblingNodeAggregateId(NodeAggregateId $succeedingSiblingNodeAggregateId): self
{
return new self(
$this->workspaceName,
$this->nodeAggregateId,
$this->nodeTypeName,
$this->originDimensionSpacePoint,
$this->parentNodeAggregateId,
$this->initialPropertyValues,
$succeedingSiblingNodeAggregateId,
$this->nodeName,
$this->tetheredDescendantNodeAggregateIds,
);
}

/**
* The node's optional name.
* Set if there is a meaningful relation to its parent that should be named.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ private function handleCreateNodeAggregateWithNode(
$command->nodeTypeName,
$command->originDimensionSpacePoint,
$command->parentNodeAggregateId,
$command->succeedingSiblingNodeAggregateId,
$this->getPropertyConverter()->serializePropertyValues(
$command->initialPropertyValues->withoutUnsets(),
$this->requireNodeType($command->nodeTypeName)
Expand All @@ -91,6 +90,9 @@ private function handleCreateNodeAggregateWithNode(
if (!$command->tetheredDescendantNodeAggregateIds->isEmpty()) {
$lowLevelCommand = $lowLevelCommand->withTetheredDescendantNodeAggregateIds($command->tetheredDescendantNodeAggregateIds);
}
if ($command->succeedingSiblingNodeAggregateId) {
$lowLevelCommand = $lowLevelCommand->withSucceedingSiblingNodeAggregateId($command->succeedingSiblingNodeAggregateId);
}
if ($command->nodeName) {
$lowLevelCommand = $lowLevelCommand->withNodeName($command->nodeName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,16 @@ public function theCommandCreateNodeAggregateWithNodeIsExecutedWithPayload(Table
NodeTypeName::fromString($commandArguments['nodeTypeName']),
$originDimensionSpacePoint,
NodeAggregateId::fromString($commandArguments['parentNodeAggregateId']),
isset($commandArguments['succeedingSiblingNodeAggregateId'])
? NodeAggregateId::fromString($commandArguments['succeedingSiblingNodeAggregateId'])
: null,
isset($commandArguments['initialPropertyValues'])
? $this->deserializeProperties($commandArguments['initialPropertyValues'])
: null,
);
if (isset($commandArguments['tetheredDescendantNodeAggregateIds'])) {
$command = $command->withTetheredDescendantNodeAggregateIds(NodeAggregateIdsByNodePaths::fromArray($commandArguments['tetheredDescendantNodeAggregateIds']));
}
if (isset($commandArguments['succeedingSiblingNodeAggregateId'])) {
$command = $command->withSucceedingSiblingNodeAggregateId(NodeAggregateId::fromString($commandArguments['succeedingSiblingNodeAggregateId']));
}
if (isset($commandArguments['nodeName'])) {
$command = $command->withNodeName(NodeName::fromString($commandArguments['nodeName']));
}
Expand Down Expand Up @@ -195,19 +195,19 @@ public function theFollowingCreateNodeAggregateWithNodeCommandsAreExecuted(Table
\str_starts_with($rawParentNodeAggregateId, '$')
? $this->rememberedNodeAggregateIds[\mb_substr($rawParentNodeAggregateId, 1)]
: NodeAggregateId::fromString($rawParentNodeAggregateId),
!empty($row['succeedingSiblingNodeAggregateId'])
? NodeAggregateId::fromString($row['succeedingSiblingNodeAggregateId'])
: null,
isset($row['nodeName'])
? NodeName::fromString($row['nodeName'])
: null,
isset($row['initialPropertyValues'])
? $this->parsePropertyValuesJsonString($row['initialPropertyValues'])
: null,
);
if (isset($row['tetheredDescendantNodeAggregateIds'])) {
$command = $command->withTetheredDescendantNodeAggregateIds(NodeAggregateIdsByNodePaths::fromJsonString($row['tetheredDescendantNodeAggregateIds']));
}
if (!empty($row['succeedingSiblingNodeAggregateId'])) {
$command = $command->withSucceedingSiblingNodeAggregateId(NodeAggregateId::fromString($row['succeedingSiblingNodeAggregateId']));
}
if (isset($row['nodeName'])) {
$command = $command->withNodeName(NodeName::fromString($row['nodeName']));
}
$this->currentContentRepository->handle($command);
}
}
Expand Down Expand Up @@ -240,16 +240,16 @@ public function theCommandCreateNodeAggregateWithNodeAndSerializedPropertiesIsEx
NodeTypeName::fromString($commandArguments['nodeTypeName']),
$originDimensionSpacePoint,
NodeAggregateId::fromString($commandArguments['parentNodeAggregateId']),
isset($commandArguments['succeedingSiblingNodeAggregateId'])
? NodeAggregateId::fromString($commandArguments['succeedingSiblingNodeAggregateId'])
: null,
isset($commandArguments['initialPropertyValues'])
? SerializedPropertyValues::fromArray($commandArguments['initialPropertyValues'])
: null
);
if (isset($commandArguments['tetheredDescendantNodeAggregateIds'])) {
$command = $command->withTetheredDescendantNodeAggregateIds(NodeAggregateIdsByNodePaths::fromArray($commandArguments['tetheredDescendantNodeAggregateIds']));
}
if (isset($commandArguments['succeedingSiblingNodeAggregateId'])) {
$command = $command->withSucceedingSiblingNodeAggregateId(NodeAggregateId::fromString($commandArguments['succeedingSiblingNodeAggregateId']));
}
if (isset($commandArguments['nodeName'])) {
$command = $command->withNodeName(NodeName::fromString($commandArguments['nodeName']));
}
Expand Down
1 change: 0 additions & 1 deletion Neos.Neos/Classes/Domain/Service/SiteServiceInternals.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ public function createSiteNodeIfNotExists(Site $site, string $nodeTypeName): voi
NodeTypeName::fromString($nodeTypeName),
OriginDimensionSpacePoint::fromDimensionSpacePoint($arbitraryRootDimensionSpacePoint),
$sitesNodeIdentifier,
null,
PropertyValuesToWrite::fromArray([
'title' => $site->getName()
])
Expand Down

0 comments on commit 30e35d5

Please sign in to comment.