From eafe146db86fe45dd0667fd36b972437d50e96ae Mon Sep 17 00:00:00 2001
From: pKallert <91674611+pKallert@users.noreply.github.com>
Date: Fri, 8 Sep 2023 17:12:29 +0200
Subject: [PATCH 1/5] Feature: Add Status Code to Shortcuts
---
.../Controller/Frontend/NodeController.php | 9 ++++++++-
.../ContentRepository/Version20230809164806.yaml | 15 +++++++++++++++
Neos.Neos/NodeTypes/Document/Shortcut.yaml | 12 ++++++++++++
.../Translations/en/NodeTypes/Shortcut.xlf | 3 +++
4 files changed, 38 insertions(+), 1 deletion(-)
create mode 100644 Neos.Neos/Migrations/ContentRepository/Version20230809164806.yaml
diff --git a/Neos.Neos/Classes/Controller/Frontend/NodeController.php b/Neos.Neos/Classes/Controller/Frontend/NodeController.php
index f529f9f3844..d2b68ad70c4 100644
--- a/Neos.Neos/Classes/Controller/Frontend/NodeController.php
+++ b/Neos.Neos/Classes/Controller/Frontend/NodeController.php
@@ -309,7 +309,14 @@ protected function handleShortcutNode(NodeAddress $nodeAddress, ContentRepositor
} else {
$resolvedUri = $resolvedTarget;
}
- $this->redirectToUri($resolvedUri);
+ $subgraph = $contentRepository->getContentGraph()->getSubgraph(
+ $nodeAddress->contentStreamId,
+ $nodeAddress->dimensionSpacePoint,
+ VisibilityConstraints::withoutRestrictions()
+ );
+ $redirectStatusCode = $subgraph->findNodeById($nodeAddress->nodeAggregateId)->getProperty('httpStatusCode');
+
+ $this->redirectToUri($resolvedUri, statusCode: $redirectStatusCode ?: 303);
}
private function fillCacheWithContentNodes(
diff --git a/Neos.Neos/Migrations/ContentRepository/Version20230809164806.yaml b/Neos.Neos/Migrations/ContentRepository/Version20230809164806.yaml
new file mode 100644
index 00000000000..7aa6be5f61a
--- /dev/null
+++ b/Neos.Neos/Migrations/ContentRepository/Version20230809164806.yaml
@@ -0,0 +1,15 @@
+comments: 'Migrate shortcut nodes: add httpStatusCode property'
+migration:
+ -
+ filters:
+ -
+ type: 'NodeType'
+ settings:
+ nodeType: 'Neos.Neos:Shortcut'
+ transformations:
+ - type: 'AddNewProperty'
+ settings:
+ newPropertyName: 'httpStatusCode'
+ serializedValue: '303'
+ type: 'int'
+
diff --git a/Neos.Neos/NodeTypes/Document/Shortcut.yaml b/Neos.Neos/NodeTypes/Document/Shortcut.yaml
index 94116d8223e..722168506c3 100644
--- a/Neos.Neos/NodeTypes/Document/Shortcut.yaml
+++ b/Neos.Neos/NodeTypes/Document/Shortcut.yaml
@@ -46,3 +46,15 @@
setTargetModeIfNotEmpty:
property: 'targetMode'
handler: 'Neos.Neos/Inspector/Handlers/ShortcutHandler'
+
+ httpStatusCode:
+ type: int
+ defaultValue: 303
+ ui:
+ label: i18n
+ inspector:
+ # change this to edit the status code in the inspector
+ hidden: true
+ group: 'document'
+ editor: 'Neos.Neos/Inspector/Editors/TextFieldEditor'
+
diff --git a/Neos.Neos/Resources/Private/Translations/en/NodeTypes/Shortcut.xlf b/Neos.Neos/Resources/Private/Translations/en/NodeTypes/Shortcut.xlf
index 294dcac151e..0f29110cda4 100644
--- a/Neos.Neos/Resources/Private/Translations/en/NodeTypes/Shortcut.xlf
+++ b/Neos.Neos/Resources/Private/Translations/en/NodeTypes/Shortcut.xlf
@@ -29,6 +29,9 @@
+
+
+