Skip to content

Commit

Permalink
TASK: Fix uriPathSegment if it depends on the title of the node creat…
Browse files Browse the repository at this point in the history
…ion data

fixes `/Features/Pages/2`

```
--- Expected
+++ Actual
@@ @@
     ],
     "properties": {
         "title": "Page1",
-        "uriPathSegment": "page1"
+        "uriPathSegment": "new-node"
     }
 }
 ```
  • Loading branch information
mhsdesign committed Aug 2, 2023
1 parent 94437e6 commit 80da04d
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions Classes/Domain/NodeCreation/NodeCreationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ public function apply(RootTemplate $template, NodeCreationCommands $commands, No
$nodeType,
$commands->first->nodeName,
$commands->first->originDimensionSpacePoint->toDimensionSpacePoint(),
$initialProperties,
$template
$initialProperties
);

return $this->applyTemplateRecursively(
Expand Down Expand Up @@ -199,8 +198,7 @@ private function applyTemplateRecursively(Templates $templates, TransientNode $p
$nodeType,
$nodeName,
$parentNode->originDimensionSpacePoint->toDimensionSpacePoint(),
$initialProperties,
$template
$initialProperties
);

$commands = $commands->withAdditionalCommands(
Expand Down Expand Up @@ -253,31 +251,27 @@ private function createReferencesCommands(ContentStreamId $contentStreamId, Node
}

/**
* All document node types get a uri path segmfent; if it is not explicitly set in the properties,
* All document node types get a uri path segment; if it is not explicitly set in the properties,
* it should be built based on the title property
*
* @param Template|RootTemplate $template
*/
private function ensureNodeHasUriPathSegment(
NodeType $nodeType,
?NodeName $nodeName,
DimensionSpacePoint $dimensionSpacePoint,
PropertyValuesToWrite $propertiesToWrite,
Template|RootTemplate $template
PropertyValuesToWrite $propertiesToWrite
): PropertyValuesToWrite {
if (!$nodeType->isOfType('Neos.Neos:Document')) {
return $propertiesToWrite;
}
$properties = $template->getProperties();
if (isset($properties['uriPathSegment'])) {
if (isset($propertiesToWrite->values['uriPathSegment'])) {
return $propertiesToWrite;
}

return $propertiesToWrite->withValue(
'uriPathSegment',
$this->generateUriPathSegment(
$dimensionSpacePoint,
$properties['title'] ?? $nodeName?->value ?? uniqid('', true)
$propertiesToWrite->values['title'] ?? $nodeName?->value ?? uniqid('', true)
)
);
}
Expand Down

0 comments on commit 80da04d

Please sign in to comment.