-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TASK: add migration to convert all node uriPathSegment to lowercase
- Loading branch information
Showing
3 changed files
with
65 additions
and
1 deletion.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
Classes/Migration/Transformation/PropertyValueToLowercase.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?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(string $propertyName): void | ||
{ | ||
$this->propertyName = $propertyName; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function isTransformable(NodeData $node) | ||
{ | ||
return $node->hasProperty($this->propertyName); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function execute(NodeData $node) | ||
{ | ||
$currentPropertyValue = $node->getProperty($this->propertyName); | ||
if (! is_string($currentPropertyValue)) { | ||
return $node; | ||
} | ||
$newPropertyValue = strtolower($currentPropertyValue); | ||
$node->setProperty($this->propertyName, $newPropertyValue); | ||
|
||
return $node; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters