Skip to content

Commit

Permalink
TASK: Adjust migration for user interface mode
Browse files Browse the repository at this point in the history
the migration previously adjusted the code to a now deprecated eel helper. In pr neos/neos-development-collection#4505 the renderingMode is introduced as global fusionValue which made an adjustment in the rector necessary.

`(node|documentNode|site).context.inBackend` is now migrated to `renderingMode.isEdit`
`(node|documentNode|site).context.live` is now migrated to `!renderingMode.isEdit`

In cases where it cannot be determined wether a node is affected by the `context` operation a comment is added as before.
  • Loading branch information
mficzel committed Sep 15, 2023
1 parent b046f7e commit 7f4b7b6
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ public function refactorFileContent(string $fileContent): string
return EelExpressionTransformer::parse($fileContent)
->process(fn(string $eelExpression) => preg_replace(
'/(node|documentNode|site)\.context\.inBackend/',
'Neos.Node.inBackend($1)',
'renderingMode.isEdit',
$eelExpression
))
->addCommentsIfRegexMatches(
'/\.context\.inBackend/',
'// TODO 9.0 migration: Line %LINE: You very likely need to rewrite "VARIABLE.context.inBackend" to Neos.Node.inBackend(VARIABLE). We did not auto-apply this migration because we cannot be sure whether the variable is a Node.'
'// TODO 9.0 migration: Line %LINE: You very likely need to rewrite "VARIABLE.context.inBackend" to "renderingMode.isEdit". We did not auto-apply this migration because we cannot be sure whether the variable is a Node.'
)->getProcessedContent();
}
}
4 changes: 2 additions & 2 deletions src/ContentRepository90/Rules/FusionContextLiveRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ public function refactorFileContent(string $fileContent): string
return EelExpressionTransformer::parse($fileContent)
->process(fn(string $eelExpression) => preg_replace(
'/(node|documentNode|site)\.context\.live/',
'Neos.Node.isLive($1)',
'!renderingMode.isEdit',
$eelExpression
))
->addCommentsIfRegexMatches(
'/\.context\.live/',
'// TODO 9.0 migration: Line %LINE: You very likely need to rewrite "VARIABLE.context.live" to Neos.Node.isLive(VARIABLE). We did not auto-apply this migration because we cannot be sure whether the variable is a Node.'
'// TODO 9.0 migration: Line %LINE: You very likely need to rewrite "VARIABLE.context.live" to "!renderingMode.isEdit". We did not auto-apply this migration because we cannot be sure whether the variable is a Node.'
)->getProcessedContent();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ prototype(Neos.Fusion.Form:Checkbox) < prototype(Neos.Fusion.Form:Component.Fie
}
}
-----
// TODO 9.0 migration: Line 26: You very likely need to rewrite "VARIABLE.context.inBackend" to Neos.Node.inBackend(VARIABLE). We did not auto-apply this migration because we cannot be sure whether the variable is a Node.
// TODO 9.0 migration: Line 26: You very likely need to rewrite "VARIABLE.context.inBackend" to "renderingMode.isEdit". We did not auto-apply this migration because we cannot be sure whether the variable is a Node.
prototype(Neos.Fusion.Form:Checkbox) < prototype(Neos.Fusion.Form:Component.Field) {

renderer = Neos.Fusion:Component {

#
# pass down props
#
attributes = ${Neos.Node.inBackend(node) || Neos.Node.inBackend(site) || Neos.Node.inBackend(documentNode)}
attributes = ${renderingMode.isEdit || renderingMode.isEdit || renderingMode.isEdit}

#
# the `checked` state is calculated outside the renderer to allow` overriding via `attributes`
Expand All @@ -54,10 +54,10 @@ prototype(Neos.Fusion.Form:Checkbox) < prototype(Neos.Fusion.Form:Component.Fie
renderer = afx`
<input
type="checkbox"
name={Neos.Node.inBackend(node)}
name={renderingMode.isEdit}
value={someOtherVariable.context.inBackend}
checked={props.checked}
{...Neos.Node.inBackend(node)}
{...renderingMode.isEdit}
/>
`
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ prototype(Neos.Fusion.Form:Checkbox) < prototype(Neos.Fusion.Form:Component.Fie
}
}
-----
// TODO 9.0 migration: Line 26: You very likely need to rewrite "VARIABLE.context.live" to Neos.Node.isLive(VARIABLE). We did not auto-apply this migration because we cannot be sure whether the variable is a Node.
// TODO 9.0 migration: Line 26: You very likely need to rewrite "VARIABLE.context.live" to "!renderingMode.isEdit". We did not auto-apply this migration because we cannot be sure whether the variable is a Node.
prototype(Neos.Fusion.Form:Checkbox) < prototype(Neos.Fusion.Form:Component.Field) {

renderer = Neos.Fusion:Component {

#
# pass down props
#
attributes = ${Neos.Node.isLive(node) || Neos.Node.isLive(site) || Neos.Node.isLive(documentNode)}
attributes = ${!renderingMode.isEdit || !renderingMode.isEdit || !renderingMode.isEdit}

#
# the `checked` state is calculated outside the renderer to allow` overriding via `attributes`
Expand All @@ -54,10 +54,10 @@ prototype(Neos.Fusion.Form:Checkbox) < prototype(Neos.Fusion.Form:Component.Fie
renderer = afx`
<input
type="checkbox"
name={Neos.Node.isLive(node)}
name={!renderingMode.isEdit}
value={someOtherVariable.context.live}
checked={props.checked}
{...Neos.Node.isLive(node)}
{...!renderingMode.isEdit}
/>
`
}
Expand Down

0 comments on commit 7f4b7b6

Please sign in to comment.