Skip to content

BUGFIX Rewrite of internal node properties in FlowQueries #64

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/ContentRepository90/Rules/FusionNodeContextPathRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@ public function refactorFileContent(string $fileContent): string
{
return EelExpressionTransformer::parse($fileContent)
->process(fn(string $eelExpression) => preg_replace(
'/(node|documentNode|site)\.contextPath/',
'/(node|documentNode|site)\.contextPath\b(?!\.|\()/',
'Neos.Node.serializedNodeAddress($1)',
$eelExpression
))
->addCommentsIfRegexMatches(
'/\.contextPath/',
'/\.contextPath\b(?!\.|\()/',
'// TODO 9.0 migration: Line %LINE: !! You very likely need to rewrite "VARIABLE.contextPath" to "Neos.Node.serializedNodeAddress(VARIABLE)". We did not auto-apply this migration because we cannot be sure whether the variable is a Node.'
)
->process(fn(string $eelExpression) => preg_replace(
'/(node|documentNode|site)\.property\\((\'|")_contextPath(\'|")\\)/',
'/q\(([^)]+)\)\.property\([\'"]_contextPath[\'"]\)/',
'Neos.Node.serializedNodeAddress($1)',
$eelExpression
))
->addCommentsIfRegexMatches(
'/\.property\\((\'|")_contextPath(\'|")\\)/',
'// TODO 9.0 migration: Line %LINE: !! You very likely need to rewrite "VARIABLE.property(\'_contextPath\')" to "Neos.Node.serializedNodeAddress(VARIABLE)". We did not auto-apply this migration because we cannot be sure whether the variable is a Node.'
'/\.property\([\'"]_contextPath[\'"]\)/',
'// TODO 9.0 migration: Line %LINE: !! You very likely need to rewrite "q(VARIABLE).property(\'_contextPath\')" to "Neos.Node.serializedNodeAddress(VARIABLE)". We did not auto-apply this migration because we cannot be sure whether the variable is a Node.'
)
->getProcessedContent();
}
Expand Down
14 changes: 7 additions & 7 deletions src/ContentRepository90/Rules/FusionNodeDepthRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,29 @@ class FusionNodeDepthRector implements FusionRectorInterface

public function getRuleDefinition(): RuleDefinition
{
return CodeSampleLoader::fromFile('Fusion: Rewrite node.depth to Neos.Node.depth(node)', __CLASS__);
return CodeSampleLoader::fromFile('Fusion: Rewrite node.depth and q(node).property("_depth") to Neos.Node.depth(node)', __CLASS__);
}

public function refactorFileContent(string $fileContent): string
{
return EelExpressionTransformer::parse($fileContent)
->process(fn(string $eelExpression) => preg_replace(
'/([a-zA-Z.]+)?(node|documentNode)\.depth/',
'/([a-zA-Z.]+)?(site|node|documentNode)\.depth\b(?!\.|\()/',
'Neos.Node.depth($1$2)',
$eelExpression
))
->addCommentsIfRegexMatches(
'/\.depth$/',
'/\.depth\b(?!\.|\()/',
'// TODO 9.0 migration: Line %LINE: You may need to rewrite "VARIABLE.depth" to Neos.Node.depth(VARIABLE). We did not auto-apply this migration because we cannot be sure whether the variable is a Node.'
)
->process(fn(string $eelExpression) => preg_replace(
'/([a-zA-Z.]+)?(node|documentNode)\.property\\((\'|")_depth(\'|")\\)/',
'Neos.Node.depth($1$2)',
'/q\(([^)]+)\)\.property\([\'"]_depth[\'"]\)/',
'Neos.Node.depth($1)',
$eelExpression
))
->addCommentsIfRegexMatches(
'/\.property\\((\'|")_depth(\'|")\\)/',
'// TODO 9.0 migration: Line %LINE: You may need to rewrite "VARIABLE.property(\'_depth\')" to Neos.Node.depth(VARIABLE). We did not auto-apply this migration because we cannot be sure whether the variable is a Node.'
'/\.property\([\'"]_depth[\'"]\)/',
'// TODO 9.0 migration: Line %LINE: You may need to rewrite "q(VARIABLE).property(\'_depth\')" to Neos.Node.depth(VARIABLE). We did not auto-apply this migration because we cannot be sure whether the variable is a Node.'
)->getProcessedContent();
}
}
15 changes: 6 additions & 9 deletions src/ContentRepository90/Rules/FusionNodeHiddenInIndexRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,26 @@ class FusionNodeHiddenInIndexRector implements FusionRectorInterface

public function getRuleDefinition(): RuleDefinition
{
return CodeSampleLoader::fromFile('Fusion: Rewrite node.hiddenInIndex to node.property(\'hiddenInIndex\')', __CLASS__);
return CodeSampleLoader::fromFile('Fusion: Rewrite node.hiddenInIndex and q(node).property("_hiddenInIndex") to node.property(\'hiddenInIndex\')', __CLASS__);
}

public function refactorFileContent(string $fileContent): string
{
return EelExpressionTransformer::parse($fileContent)
->process(fn(string $eelExpression) => preg_replace(
'/(node|documentNode|site)\.hiddenInIndex/',
'/(node|documentNode|site)\.hiddenInIndex\b(?!\.|\()/',
'$1.property(\'hiddenInIndex\')',
$eelExpression
))
->addCommentsIfRegexMatches(
'/\.hiddenInIndex/',
'/\.hiddenInIndex\b(?!\.|\()/',
'// TODO 9.0 migration: Line %LINE: You may need to rewrite "VARIABLE.hiddenInIndex" to VARIABLE.property(\'hiddenInIndex\'). We did not auto-apply this migration because we cannot be sure whether the variable is a Node.'
)
->process(fn(string $eelExpression) => preg_replace(
'/([a-zA-Z.]+(node|documentNode))\.property\\(\'_hiddenInIndex\'\\)/',
'$1.property(\'hiddenInIndex\')',
'/\.property\([\'"]_hiddenInIndex[\'"]\)/',
'.property(\'hiddenInIndex\')',
$eelExpression
))
->addCommentsIfRegexMatches(
'/\.property\\(\'_hiddenInIndex\'\\)/',
'// TODO 9.0 migration: Line %LINE: You may need to rewrite "VARIABLE.property(\'_hiddenInIndex\')" to VARIABLE.property(\'hiddenInIndex\'). We did not auto-apply this migration because we cannot be sure whether the variable is a Node.'
)
)->getProcessedContent();
}
}
14 changes: 5 additions & 9 deletions src/ContentRepository90/Rules/FusionNodePathRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,26 @@ class FusionNodePathRector implements FusionRectorInterface

public function getRuleDefinition(): RuleDefinition
{
return CodeSampleLoader::fromFile('Fusion: Rewrite node.path to Neos.Node.path(node)', __CLASS__);
return CodeSampleLoader::fromFile('Fusion: Rewrite node.path and q(node).property("_path") to Neos.Node.path(node)', __CLASS__);
}

public function refactorFileContent(string $fileContent): string
{
return EelExpressionTransformer::parse($fileContent)
->process(fn(string $eelExpression) => preg_replace(
'/(node|documentNode|site)\.path/',
'/(node|documentNode|site)\.path\b(?!\.|\()/',
'Neos.Node.path($1)',
$eelExpression
))
->addCommentsIfRegexMatches(
'/\.path$/',
'/\.path\b(?!\.|\()/',
'// TODO 9.0 migration: Line %LINE: You may need to rewrite "VARIABLE.path" to Neos.Node.path(VARIABLE). We did not auto-apply this migration because we cannot be sure whether the variable is a Node.'
)
->process(fn(string $eelExpression) => preg_replace(
'/(node|documentNode|site)\.property\\(\'_path\'\\)/',
'/q\(([^)]+)\)\.property\([\'"]_path[\'"]\)/',
'Neos.Node.path($1)',
$eelExpression
))
->addCommentsIfRegexMatches(
'/\.property\\(\'_path\'\\)/',
'// TODO 9.0 migration: Line %LINE: You may need to rewrite "VARIABLE.property(\'_path\')" to Neos.Node.path(VARIABLE). We did not auto-apply this migration because we cannot be sure whether the variable is a Node.'
)
->getProcessedContent();
)->getProcessedContent();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ prototype(Neos.Fusion.Form:Checkbox) < prototype(Neos.Fusion.Form:Component.Fie
#
# pass down props
#
attributes = ${node.contextPath || documentNode.contextPath || node.property('_contextPath') || documentNode.property("_contextPath")}
foo = ${bar.property('_contextPath') || bar.property("_contextPath")}
attributes = ${node.contextPath || documentNode.contextPath || q(node).property('_contextPath') || q(documentNode).property("_contextPath")}
foo = ${q(bar).property('_contextPath') || q(bar).property("_contextPath")}
boo = ${q(nodes).first().property('_contextPath') || q(nodes).first().property("_contextPath")}

#
# the `checked` state is calculated outside the renderer to allow` overriding via `attributes`
Expand All @@ -31,8 +32,8 @@ prototype(Neos.Fusion.Form:Checkbox) < prototype(Neos.Fusion.Form:Component.Fie
}
}
-----
// TODO 9.0 migration: Line 11: !! You very likely need to rewrite "VARIABLE.property('_contextPath')" to "Neos.Node.serializedNodeAddress(VARIABLE)". We did not auto-apply this migration because we cannot be sure whether the variable is a Node.
// TODO 9.0 migration: Line 27: !! You very likely need to rewrite "VARIABLE.contextPath" to "Neos.Node.serializedNodeAddress(VARIABLE)". We did not auto-apply this migration because we cannot be sure whether the variable is a Node.
// TODO 9.0 migration: Line 12: !! You very likely need to rewrite "q(VARIABLE).property('_contextPath')" to "Neos.Node.serializedNodeAddress(VARIABLE)". We did not auto-apply this migration because we cannot be sure whether the variable is a Node.
// TODO 9.0 migration: Line 28: !! You very likely need to rewrite "VARIABLE.contextPath" to "Neos.Node.serializedNodeAddress(VARIABLE)". 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 {
Expand All @@ -41,7 +42,8 @@ prototype(Neos.Fusion.Form:Checkbox) < prototype(Neos.Fusion.Form:Component.Fie
# pass down props
#
attributes = ${Neos.Node.serializedNodeAddress(node) || Neos.Node.serializedNodeAddress(documentNode) || Neos.Node.serializedNodeAddress(node) || Neos.Node.serializedNodeAddress(documentNode)}
foo = ${bar.property('_contextPath') || bar.property("_contextPath")}
foo = ${Neos.Node.serializedNodeAddress(bar) || Neos.Node.serializedNodeAddress(bar)}
boo = ${q(nodes).first().property('_contextPath') || q(nodes).first().property("_contextPath")}

#
# the `checked` state is calculated outside the renderer to allow` overriding via `attributes`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ prototype(Neos.Fusion.Form:Checkbox) < prototype(Neos.Fusion.Form:Component.Fie
#
# pass down props
#
attributes = ${node.depth || documentNode.depth || node.property('_depth') || documentNode.property("_depth")}
foo = ${bar.property('_depth') || bar.property("_depth")}
attributes = ${node.depth || documentNode.depth || q(node).property('_depth') || q(documentNode).property("_depth")}
foo = ${q(bar).property('_depth') || q(bar).property("_depth")}
boo = ${q(nodes).first().property('_depth') || q(nodes).first().property("_depth")}

#
# the `checked` state is calculated outside the renderer to allow` overriding via `attributes`
Expand All @@ -23,16 +24,18 @@ prototype(Neos.Fusion.Form:Checkbox) < prototype(Neos.Fusion.Form:Component.Fie
<input
type="checkbox"
name={node.depth}
value={someOtherVariable.depth}
value={someOtherVariable.depth || something}
path={someOtherVariable.depth}
checked={props.checked}
{...node.depth}
/>
`
}
}
-----
// TODO 9.0 migration: Line 11: You may need to rewrite "VARIABLE.property('_depth')" to Neos.Node.depth(VARIABLE). We did not auto-apply this migration because we cannot be sure whether the variable is a Node.
// TODO 9.0 migration: Line 27: You may need to rewrite "VARIABLE.depth" to Neos.Node.depth(VARIABLE). We did not auto-apply this migration because we cannot be sure whether the variable is a Node.
// TODO 9.0 migration: Line 13: You may need to rewrite "q(VARIABLE).property('_depth')" to Neos.Node.depth(VARIABLE). We did not auto-apply this migration because we cannot be sure whether the variable is a Node.
// TODO 9.0 migration: Line 29: You may need to rewrite "VARIABLE.depth" to Neos.Node.depth(VARIABLE). We did not auto-apply this migration because we cannot be sure whether the variable is a Node.
// TODO 9.0 migration: Line 30: You may need to rewrite "VARIABLE.depth" to Neos.Node.depth(VARIABLE). 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 {
Expand All @@ -41,7 +44,8 @@ prototype(Neos.Fusion.Form:Checkbox) < prototype(Neos.Fusion.Form:Component.Fie
# pass down props
#
attributes = ${Neos.Node.depth(node) || Neos.Node.depth(documentNode) || Neos.Node.depth(node) || Neos.Node.depth(documentNode)}
foo = ${bar.property('_depth') || bar.property("_depth")}
foo = ${Neos.Node.depth(bar) || Neos.Node.depth(bar)}
boo = ${q(nodes).first().property('_depth') || q(nodes).first().property("_depth")}

#
# the `checked` state is calculated outside the renderer to allow` overriding via `attributes`
Expand All @@ -58,7 +62,8 @@ prototype(Neos.Fusion.Form:Checkbox) < prototype(Neos.Fusion.Form:Component.Fie
<input
type="checkbox"
name={Neos.Node.depth(node)}
value={someOtherVariable.depth}
value={someOtherVariable.depth || something}
path={someOtherVariable.depth}
checked={props.checked}
{...Neos.Node.depth(node)}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ prototype(Neos.Fusion.Form:Checkbox) < prototype(Neos.Fusion.Form:Component.Fie
#
# pass down props
#
attributes = ${node.hiddenInIndex || documentNode.hiddenInIndex || site.hiddenInIndex}
attributes = ${node.hiddenInIndex || documentNode.hiddenInIndex || site.hiddenInIndex || q(node).property('_hiddenInIndex') || q(documentNode).property("_hiddenInIndex")}

#
# the `checked` state is calculated outside the renderer to allow` overriding via `attributes`
Expand Down Expand Up @@ -38,7 +38,7 @@ prototype(Neos.Fusion.Form:Checkbox) < prototype(Neos.Fusion.Form:Component.Fie
#
# pass down props
#
attributes = ${node.property('hiddenInIndex') || documentNode.property('hiddenInIndex') || site.property('hiddenInIndex')}
attributes = ${node.property('hiddenInIndex') || documentNode.property('hiddenInIndex') || site.property('hiddenInIndex') || q(node).property('hiddenInIndex') || q(documentNode).property('hiddenInIndex')}

#
# the `checked` state is calculated outside the renderer to allow` overriding via `attributes`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ prototype(Neos.Fusion.Form:Checkbox) < prototype(Neos.Fusion.Form:Component.Fie
#
# pass down props
#
attributes = ${node.path || documentNode.path}
attributes = ${node.path || documentNode.path || q(node).property('_path') || q(documentNode).property("_path")}
foo = ${q(bar).property('_path') || q(bar).property("_path")}
boo = ${q(nodes).first().property('_path') || q(nodes).first().property("_path")}

#
# the `checked` state is calculated outside the renderer to allow` overriding via `attributes`
Expand All @@ -22,23 +24,27 @@ prototype(Neos.Fusion.Form:Checkbox) < prototype(Neos.Fusion.Form:Component.Fie
<input
type="checkbox"
name={node.path}
value={someOtherVariable.path}
value={someOtherVariable.path || something}
path={someOtherVariable.path}
checked={props.checked}
{...node.path}
/>
`
}
}
-----
// TODO 9.0 migration: Line 26: You may need to rewrite "VARIABLE.path" to Neos.Node.path(VARIABLE). We did not auto-apply this migration because we cannot be sure whether the variable is a Node.
// TODO 9.0 migration: Line 29: You may need to rewrite "VARIABLE.path" to Neos.Node.path(VARIABLE). We did not auto-apply this migration because we cannot be sure whether the variable is a Node.
// TODO 9.0 migration: Line 30: You may need to rewrite "VARIABLE.path" to Neos.Node.path(VARIABLE). 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.path(node) || Neos.Node.path(documentNode)}
attributes = ${Neos.Node.path(node) || Neos.Node.path(documentNode) || Neos.Node.path(node) || Neos.Node.path(documentNode)}
foo = ${Neos.Node.path(bar) || Neos.Node.path(bar)}
boo = ${q(nodes).first().property('_path') || q(nodes).first().property("_path")}

#
# the `checked` state is calculated outside the renderer to allow` overriding via `attributes`
Expand All @@ -55,7 +61,8 @@ prototype(Neos.Fusion.Form:Checkbox) < prototype(Neos.Fusion.Form:Component.Fie
<input
type="checkbox"
name={Neos.Node.path(node)}
value={someOtherVariable.path}
value={someOtherVariable.path || something}
path={someOtherVariable.path}
checked={props.checked}
{...Neos.Node.path(node)}
/>
Expand Down
Loading