-
-
Notifications
You must be signed in to change notification settings - Fork 221
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5330 from dlubitz/90/feature/root-node-type-mapping
FEATURE: Allow mapping of legacy root paths to RootNodeAggregate NodeTypeNames
- Loading branch information
Showing
8 changed files
with
135 additions
and
31 deletions.
There are no files selected for viewing
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
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
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
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
31 changes: 31 additions & 0 deletions
31
Neos.ContentRepository.LegacyNodeMigration/Classes/RootNodeTypeMapping.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,31 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Neos\ContentRepository\LegacyNodeMigration; | ||
|
||
use Neos\ContentRepository\Core\NodeType\NodeTypeName; | ||
|
||
class RootNodeTypeMapping | ||
{ | ||
/** | ||
* @param array<string, string> $mapping | ||
*/ | ||
private function __construct( | ||
public readonly array $mapping, | ||
) { | ||
} | ||
|
||
/** | ||
* @param array<string, string> $mapping | ||
* @return self | ||
*/ | ||
public static function fromArray(array $mapping): self | ||
{ | ||
return new self($mapping); | ||
} | ||
|
||
public function getByPath(string $path): ?NodeTypeName | ||
{ | ||
return isset($this->mapping[$path]) ? NodeTypeName::fromString($this->mapping[$path]) : null; | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
Neos.ContentRepository.LegacyNodeMigration/Configuration/Settings.yaml
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,6 @@ | ||
Neos: | ||
ContentRepository: | ||
LegacyNodeMigration: | ||
rootNodeMapping: | ||
default: | ||
'/sites': 'Neos.Neos:Sites' |
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
46 changes: 46 additions & 0 deletions
46
...ContentRepository.LegacyNodeMigration/Tests/Behavior/Features/RootNodeTypeMapping.feature
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,46 @@ | ||
@contentrepository | ||
Feature: Simple migrations without content dimensions but other root nodetype name | ||
|
||
Background: | ||
Given using no content dimensions | ||
And using the following node types: | ||
"""yaml | ||
'Neos.Neos:Site': {} | ||
'Some.Package:Homepage': | ||
superTypes: | ||
'Neos.Neos:Site': true | ||
properties: | ||
'text': | ||
type: string | ||
defaultValue: 'My default text' | ||
""" | ||
And using identifier "default", I define a content repository | ||
And I am in content repository "default" | ||
|
||
Scenario: Migration without rootNodeType configuration for all root nodes | ||
When I have the following node data rows: | ||
| Identifier | Path | Node Type | Properties | | ||
| sites-node-id | /sites | unstructured | | | ||
| site-node-id | /sites/test-site | Some.Package:Homepage | {"text": "foo"} | | ||
| test-root-node-id | /test | unstructured | | | ||
| test-node-id | /test/test-site | Some.Package:Homepage | {"text": "foo"} | | ||
And I run the event migration for content stream "cs-id" | ||
Then I expect the following errors to be logged | ||
| Failed to find parent node for node with id "test-root-node-id" and dimensions: []. Please ensure that the new content repository has a valid content dimension configuration. Also note that the old CR can sometimes have orphaned nodes. | | ||
| Failed to find parent node for node with id "test-node-id" and dimensions: []. Please ensure that the new content repository has a valid content dimension configuration. Also note that the old CR can sometimes have orphaned nodes. | | ||
|
||
|
||
Scenario: Migration with rootNodeType configuration for all root nodes | ||
When I have the following node data rows: | ||
| Identifier | Path | Node Type | Properties | | ||
| sites-node-id | /sites | unstructured | | | ||
| site-node-id | /sites/test-site | Some.Package:Homepage | {"text": "foo"} | | ||
| test-root-node-id | /test | unstructured | | | ||
| test-node-id | /test/test-site | Some.Package:Homepage | {"text": "foo"} | | ||
And I run the event migration for content stream "cs-id" with rootNode mapping {"/sites": "Neos.Neos:Sites", "/test": "Neos.ContentRepository.LegacyNodeMigration:TestRoot"} | ||
Then I expect the following events to be exported | ||
| Type | Payload | | ||
| RootNodeAggregateWithNodeWasCreated | {"contentStreamId": "cs-id", "nodeAggregateId": "sites-node-id", "nodeTypeName": "Neos.Neos:Sites", "nodeAggregateClassification": "root"} | | ||
| NodeAggregateWithNodeWasCreated | {"contentStreamId": "cs-id", "nodeAggregateId": "site-node-id", "nodeTypeName": "Some.Package:Homepage", "nodeName": "test-site", "parentNodeAggregateId": "sites-node-id", "nodeAggregateClassification": "regular", "initialPropertyValues": {"text": {"type": "string", "value": "foo"}}} | | ||
| RootNodeAggregateWithNodeWasCreated | {"contentStreamId": "cs-id", "nodeAggregateId": "test-root-node-id", "nodeTypeName": "Neos.ContentRepository.LegacyNodeMigration:TestRoot", "nodeAggregateClassification": "root"} | | ||
| NodeAggregateWithNodeWasCreated | {"contentStreamId": "cs-id", "nodeAggregateId": "test-node-id", "nodeTypeName": "Some.Package:Homepage", "nodeName": "test-site", "parentNodeAggregateId": "test-root-node-id", "nodeAggregateClassification": "regular", "initialPropertyValues": {"text": {"type": "string", "value": "foo"}}} | |