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 userInterfaceMode is introduced as global fusionValue which made an adjustment in the rector necessary.

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

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 14, 2023
1 parent b046f7e commit d04a7ef
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)',
'userInterfaceMode.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 "userInterfaceMode.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)',
'userInterfaceMode.isLive',
$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 "userInterfaceMode.isLive". 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 "userInterfaceMode.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 = ${userInterfaceMode.isEdit || userInterfaceMode.isEdit || userInterfaceMode.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={userInterfaceMode.isEdit}
value={someOtherVariable.context.inBackend}
checked={props.checked}
{...Neos.Node.inBackend(node)}
{...userInterfaceMode.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 "userInterfaceMode.isLive". 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 = ${userInterfaceMode.isLive || userInterfaceMode.isLive || userInterfaceMode.isLive}

#
# 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={userInterfaceMode.isLive}
value={someOtherVariable.context.live}
checked={props.checked}
{...Neos.Node.isLive(node)}
{...userInterfaceMode.isLive}
/>
`
}
Expand Down

0 comments on commit d04a7ef

Please sign in to comment.