Skip to content

Commit

Permalink
TASK: add migration to convert all node uriPathSegment to lowercase
Browse files Browse the repository at this point in the history
  • Loading branch information
t-heuser committed Jan 24, 2025
1 parent a074c64 commit aee6e7e
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
36 changes: 36 additions & 0 deletions Classes/Migration/Transformation/PropertyValueToLowercase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

declare(strict_types=1);

namespace Flowpack\SeoRouting\Migration\Transformation;

use Neos\ContentRepository\Domain\Model\NodeData;
use Neos\ContentRepository\Migration\Transformations\AbstractTransformation;

class PropertyValueToLowercase extends AbstractTransformation
{
private string $propertyName;

public function setProperty($propertyName): void

Check failure on line 14 in Classes/Migration/Transformation/PropertyValueToLowercase.php

View workflow job for this annotation

GitHub Actions / phpstan

Method Flowpack\SeoRouting\Migration\Transformation\PropertyValueToLowercase::setProperty() has parameter $propertyName with no type specified.
{
$this->propertyName = $propertyName;

Check failure on line 16 in Classes/Migration/Transformation/PropertyValueToLowercase.php

View workflow job for this annotation

GitHub Actions / phpstan

Property Flowpack\SeoRouting\Migration\Transformation\PropertyValueToLowercase::$propertyName (string) does not accept mixed.
}

/**
* @inheritDoc
*/
public function isTransformable(NodeData $node): bool
{
return $node->hasProperty($this->propertyName);
}

/**
* @inheritDoc
*/
public function execute(NodeData $node): void

Check failure on line 30 in Classes/Migration/Transformation/PropertyValueToLowercase.php

View workflow job for this annotation

GitHub Actions / phpstan

Return type (void) of method Flowpack\SeoRouting\Migration\Transformation\PropertyValueToLowercase::execute() should be compatible with return type (Neos\ContentRepository\Domain\Model\NodeData) of method Neos\ContentRepository\Migration\Transformations\AbstractTransformation::execute()

Check failure on line 30 in Classes/Migration/Transformation/PropertyValueToLowercase.php

View workflow job for this annotation

GitHub Actions / phpstan

Return type (void) of method Flowpack\SeoRouting\Migration\Transformation\PropertyValueToLowercase::execute() should be compatible with return type (Neos\ContentRepository\Domain\Model\NodeData) of method Neos\ContentRepository\Migration\Transformations\TransformationInterface::execute()
{
$currentPropertyValue = $node->getProperty($this->propertyName);
$newPropertyValue = strtolower($currentPropertyValue);

Check failure on line 33 in Classes/Migration/Transformation/PropertyValueToLowercase.php

View workflow job for this annotation

GitHub Actions / phpstan

Parameter #1 $string of function strtolower expects string, mixed given.
$node->setProperty($this->propertyName, $newPropertyValue);
}
}
16 changes: 16 additions & 0 deletions Migrations/ContentRepository/Version20250124153030.yaml
Original file line number Diff line number Diff line change
@@ -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'

0 comments on commit aee6e7e

Please sign in to comment.