diff --git a/Neos.Neos/Classes/Fusion/Helper/ArrayHelper.php b/Neos.Neos/Classes/Fusion/Helper/ArrayHelper.php index 65097ab559a..ade31b9fa0f 100644 --- a/Neos.Neos/Classes/Fusion/Helper/ArrayHelper.php +++ b/Neos.Neos/Classes/Fusion/Helper/ArrayHelper.php @@ -15,6 +15,7 @@ use Neos\Eel\ProtectedContextAwareInterface; use Neos\Flow\Annotations as Flow; use Neos\Utility\ObjectAccess; +use Neos\Utility\PositionalArraySorter; /** * Some Functional Programming Array helpers for Eel contexts @@ -90,6 +91,14 @@ public function groupBy($set, $groupingKey) return $result; } + /** + * Sorts the input array by the $positionProperty of each element. + */ + public function sortByPropertyPath(array $set, $positionPropertyPath = 'position'): array + { + return (new PositionalArraySorter($set, $positionPropertyPath))->toArray(); + } + /** * All methods are considered safe * diff --git a/Neos.Neos/Documentation/References/EelHelpersReference.rst b/Neos.Neos/Documentation/References/EelHelpersReference.rst index 3261a73218d..5005ce26cb8 100644 --- a/Neos.Neos/Documentation/References/EelHelpersReference.rst +++ b/Neos.Neos/Documentation/References/EelHelpersReference.rst @@ -1214,6 +1214,16 @@ The input is assumed to be an array or Collection of objects. Groups this input **Return** (array) +Neos.Array.sortByPropertyPath(set, positionPropertyPath) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The input is assumed to be an array. Sorts this input by the $positionPropertyPath property of each element. + +* ``set`` (array) +* ``positionPropertyPath`` (string) + +**Return** (array) + @@ -2467,8 +2477,3 @@ Get the variable type * ``variable`` (mixed) **Return** (string) - - - - - diff --git a/Neos.Neos/Resources/Private/Fusion/RawContent/NodeProperties.fusion b/Neos.Neos/Resources/Private/Fusion/RawContent/NodeProperties.fusion index 484a54d8702..1f22a265684 100644 --- a/Neos.Neos/Resources/Private/Fusion/RawContent/NodeProperties.fusion +++ b/Neos.Neos/Resources/Private/Fusion/RawContent/NodeProperties.fusion @@ -1,7 +1,12 @@ prototype(Neos.Neos:RawContent.NodeProperties) < prototype(Neos.Fusion:Component) { + @private { + items = ${node.nodeType.properties} + items.@process.sort = ${Neos.Array.sortByPropertyPath(value, 'ui.inspector.position')} + } + renderer = afx`
- +