Skip to content

Commit a12aaa5

Browse files
jonnittodimaip
authored andcommitted
BUGFIX: Allow set of uriPathSegment via template (#26)
1 parent 809e1da commit a12aaa5

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

Classes/NodeCreationHandler/TemplatingDocumentTitleNodeCreationHandler.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class TemplatingDocumentTitleNodeCreationHandler implements NodeCreationHandlerI
3333
public function handle(NodeInterface $node, array $data)
3434
{
3535
$title = null;
36+
$uriPathSegment = null;
3637

3738
if (!$node->getNodeType()->isOfType('Neos.Neos:Document')) {
3839
return;
@@ -52,8 +53,26 @@ public function handle(NodeInterface $node, array $data)
5253
$title = $this->eelEvaluationService->evaluateEelExpression($titleTemplate, $context);
5354
}
5455
}
56+
57+
$uriPathSegmentTemplate = $node->getNodeType()->getOptions()['template']['properties']['uriPathSegment'] ?? '';
58+
if ($uriPathSegmentTemplate === '') {
59+
$uriPathSegment = $data['uriPathSegment'] ?? null;
60+
} else {
61+
if (preg_match(Package::EelExpressionRecognizer, $uriPathSegmentTemplate)) {
62+
$context = [
63+
'data' => $data,
64+
'triggeringNode' => $node,
65+
];
66+
67+
$uriPathSegment = $this->eelEvaluationService->evaluateEelExpression($uriPathSegmentTemplate, $context);
68+
}
69+
}
70+
71+
if (!isset($uriPathSegment) || $uriPathSegment === '') {
72+
$uriPathSegment = $title;
73+
}
5574

5675
$node->setProperty('title', (string) $title);
57-
$node->setProperty('uriPathSegment', $this->nodeUriPathSegmentGenerator->generateUriPathSegment($node, $title));
76+
$node->setProperty('uriPathSegment', $this->nodeUriPathSegmentGenerator->generateUriPathSegment($node, $uriPathSegment));
5877
}
5978
}

0 commit comments

Comments
 (0)