From aee6e7e0329afee3612171c38d0cc962e2d0a5e9 Mon Sep 17 00:00:00 2001 From: Timon Heuser Date: Fri, 24 Jan 2025 15:36:44 +0100 Subject: [PATCH] TASK: add migration to convert all node uriPathSegment to lowercase --- .../PropertyValueToLowercase.php | 36 +++++++++++++++++++ .../Version20250124153030.yaml | 16 +++++++++ 2 files changed, 52 insertions(+) create mode 100644 Classes/Migration/Transformation/PropertyValueToLowercase.php create mode 100644 Migrations/ContentRepository/Version20250124153030.yaml diff --git a/Classes/Migration/Transformation/PropertyValueToLowercase.php b/Classes/Migration/Transformation/PropertyValueToLowercase.php new file mode 100644 index 0000000..bc99852 --- /dev/null +++ b/Classes/Migration/Transformation/PropertyValueToLowercase.php @@ -0,0 +1,36 @@ +propertyName = $propertyName; + } + + /** + * @inheritDoc + */ + public function isTransformable(NodeData $node): bool + { + return $node->hasProperty($this->propertyName); + } + + /** + * @inheritDoc + */ + public function execute(NodeData $node): void + { + $currentPropertyValue = $node->getProperty($this->propertyName); + $newPropertyValue = strtolower($currentPropertyValue); + $node->setProperty($this->propertyName, $newPropertyValue); + } +} diff --git a/Migrations/ContentRepository/Version20250124153030.yaml b/Migrations/ContentRepository/Version20250124153030.yaml new file mode 100644 index 0000000..a17f8d7 --- /dev/null +++ b/Migrations/ContentRepository/Version20250124153030.yaml @@ -0,0 +1,16 @@ +up: + comments: 'Transforms all uriPathSegment values to lowercase' + warnings: 'As this migration removes the distinction between uppercase and lowercase it might not be cleanly undone by the down migration.' + migration: + - filters: + - type: 'NodeType' + settings: + nodeType: 'Neos.Neos:Document' + withSubTypes: TRUE + transformations: + - type: 'Flowpack\SeoRouting\Migration\Transformation\PropertyValueToLowercase' + settings: + property: 'uriPathSegment' + +down: + comments: 'No down migration available'