Skip to content

Commit

Permalink
FEATURE: Improve context rewrites in fusion
Browse files Browse the repository at this point in the history
  • Loading branch information
dlubitz committed Dec 23, 2024
1 parent d17993a commit 8411258
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function refactorFileContent(string $fileContent): string
{
return EelExpressionTransformer::parse($fileContent)
->process(fn(string $eelExpression) => preg_replace(
'/(node|documentNode|site)\.context\.workspaceName/',
'/(node|documentNode|site)\.context\.(workspaceName|workspace\.name)\b/',
'$1.workspaceName',
$eelExpression
))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
prototype(Neos.Context:Prototype) < prototype(Neos.Fusion:Component) {

workspaceName = ${node.context.workspaceName}
workspaceNameByWorkspace = ${node.context.workspace.name}

attributes = ${node.context.workspaceName || site.context.workspaceName || documentNode.context.workspaceName}

Expand All @@ -14,10 +15,11 @@ prototype(Neos.Context:Prototype) < prototype(Neos.Fusion:Component) {
`
}
-----
// TODO 9.0 migration: Line 13: You very likely need to rewrite "VARIABLE.context.workspaceName" to "VARIABLE.workspaceName". We did not auto-apply this migration because we cannot be sure whether the variable is a Node.
// TODO 9.0 migration: Line 14: You very likely need to rewrite "VARIABLE.context.workspaceName" to "VARIABLE.workspaceName". We did not auto-apply this migration because we cannot be sure whether the variable is a Node.
prototype(Neos.Context:Prototype) < prototype(Neos.Fusion:Component) {

workspaceName = ${node.workspaceName}
workspaceNameByWorkspace = ${node.workspaceName}

attributes = ${node.workspaceName || site.workspaceName || documentNode.workspaceName}

Expand Down
20 changes: 11 additions & 9 deletions tests/Sets/ContentRepository90/Fixture/Context/context.fusion.inc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
prototype(Neos.Context:Prototype) < prototype(Neos.Fusion:Component) {

workspaceName = ${node.context.workspaceName}
workspaceNameByWorkspace = ${node.context.workspace.name}
rootNode = ${node.context.rootNode}

currentDateTime = ${node.context.currentDateTime}
Expand All @@ -18,18 +19,19 @@ prototype(Neos.Context:Prototype) < prototype(Neos.Fusion:Component) {

}
-----
// TODO 9.0 migration: Line 13: !! node.context.rootNode is removed in Neos 9.0.
// TODO 9.0 migration: Line 15: !! node.context.currentDateTime is removed in Neos 9.0.
// TODO 9.0 migration: Line 16: !! node.context.dimensions is removed in Neos 9.0. You can get node DimensionSpacePoints via node.dimensionSpacePoints now.
// TODO 9.0 migration: Line 17: !! node.context.properties is removed in Neos 9.0.
// TODO 9.0 migration: Line 19: !! node.context.targetDimensions is removed in Neos 9.0.
// TODO 9.0 migration: Line 20: !! node.context.targetDimensionValues is removed in Neos 9.0.
// TODO 9.0 migration: Line 24: !! node.context.isInaccessibleContentShown is removed in Neos 9.0.
// TODO 9.0 migration: Line 25: !! node.context.isInvisibleContentShown is removed in Neos 9.0.
// TODO 9.0 migration: Line 26: !! node.context.isRemovedContentShown is removed in Neos 9.0.
// TODO 9.0 migration: Line 14: !! node.context.rootNode is removed in Neos 9.0.
// TODO 9.0 migration: Line 16: !! node.context.currentDateTime is removed in Neos 9.0.
// TODO 9.0 migration: Line 17: !! node.context.dimensions is removed in Neos 9.0. You can get node DimensionSpacePoints via node.dimensionSpacePoints now.
// TODO 9.0 migration: Line 18: !! node.context.properties is removed in Neos 9.0.
// TODO 9.0 migration: Line 20: !! node.context.targetDimensions is removed in Neos 9.0.
// TODO 9.0 migration: Line 21: !! node.context.targetDimensionValues is removed in Neos 9.0.
// TODO 9.0 migration: Line 25: !! node.context.isInaccessibleContentShown is removed in Neos 9.0.
// TODO 9.0 migration: Line 26: !! node.context.isInvisibleContentShown is removed in Neos 9.0.
// TODO 9.0 migration: Line 27: !! node.context.isRemovedContentShown is removed in Neos 9.0.
prototype(Neos.Context:Prototype) < prototype(Neos.Fusion:Component) {

workspaceName = ${node.workspaceName}
workspaceNameByWorkspace = ${node.workspaceName}
rootNode = ${node.context.rootNode}

currentDateTime = ${node.context.currentDateTime}
Expand Down

0 comments on commit 8411258

Please sign in to comment.