Skip to content

Commit aee6e7e

Browse files
committed
TASK: add migration to convert all node uriPathSegment to lowercase
1 parent a074c64 commit aee6e7e

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Flowpack\SeoRouting\Migration\Transformation;
6+
7+
use Neos\ContentRepository\Domain\Model\NodeData;
8+
use Neos\ContentRepository\Migration\Transformations\AbstractTransformation;
9+
10+
class PropertyValueToLowercase extends AbstractTransformation
11+
{
12+
private string $propertyName;
13+
14+
public function setProperty($propertyName): void
15+
{
16+
$this->propertyName = $propertyName;
17+
}
18+
19+
/**
20+
* @inheritDoc
21+
*/
22+
public function isTransformable(NodeData $node): bool
23+
{
24+
return $node->hasProperty($this->propertyName);
25+
}
26+
27+
/**
28+
* @inheritDoc
29+
*/
30+
public function execute(NodeData $node): void
31+
{
32+
$currentPropertyValue = $node->getProperty($this->propertyName);
33+
$newPropertyValue = strtolower($currentPropertyValue);
34+
$node->setProperty($this->propertyName, $newPropertyValue);
35+
}
36+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
up:
2+
comments: 'Transforms all uriPathSegment values to lowercase'
3+
warnings: 'As this migration removes the distinction between uppercase and lowercase it might not be cleanly undone by the down migration.'
4+
migration:
5+
- filters:
6+
- type: 'NodeType'
7+
settings:
8+
nodeType: 'Neos.Neos:Document'
9+
withSubTypes: TRUE
10+
transformations:
11+
- type: 'Flowpack\SeoRouting\Migration\Transformation\PropertyValueToLowercase'
12+
settings:
13+
property: 'uriPathSegment'
14+
15+
down:
16+
comments: 'No down migration available'

0 commit comments

Comments
 (0)