Skip to content

Commit

Permalink
Merge pull request #45 from neos/task/4208-remove-internal-properties
Browse files Browse the repository at this point in the history
TASK: Remove "internal" node properties
  • Loading branch information
dlubitz authored Apr 12, 2024
2 parents c0b44f7 + ae11045 commit d7c832e
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 16 deletions.
2 changes: 1 addition & 1 deletion config/set/contentrepository-90.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
$rectorConfig->rule(NodeIsHiddenInIndexRector::class);
// Fusion: .hiddenInIndex -> node.properties._hiddenInIndex
$rectorConfig->rule(FusionNodeHiddenInIndexRector::class);
$fusionFlowQueryPropertyToComments[] = new FusionFlowQueryNodePropertyToWarningComment('_hiddenInIndex', 'Line %LINE: !! You very likely need to rewrite "q(VARIABLE).property("_hiddenInIndex")" to "VARIABLE.properties._hiddenInIndex". We did not auto-apply this migration because we cannot be sure whether the variable is a Node.');
$fusionFlowQueryPropertyToComments[] = new FusionFlowQueryNodePropertyToWarningComment('_hiddenInIndex', 'Line %LINE: !! You very likely need to rewrite "q(VARIABLE).property("_hiddenInIndex")" to "VARIABLE.property(\'hiddenInMenu\')". We did not auto-apply this migration because we cannot be sure whether the variable is a Node.');
// setAccessRoles
$methodCallToWarningComments[] = new MethodCallToWarningComment(NodeLegacyStub::class, 'setAccessRoles', '!! Node::setAccessRoles() is not supported by the new CR.');
// getAccessRoles
Expand Down
12 changes: 11 additions & 1 deletion src/ContentRepository90/Rules/FusionNodeContextPathRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ public function refactorFileContent(string $fileContent): string
->addCommentsIfRegexMatches(
'/\.contextPath/',
'// 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.'
)->getProcessedContent();
)
->process(fn(string $eelExpression) => preg_replace(
'/(node|documentNode|site)\.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.'
)
->getProcessedContent();
}
}
9 changes: 9 additions & 0 deletions src/ContentRepository90/Rules/FusionNodeDepthRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ public function refactorFileContent(string $fileContent): string
->addCommentsIfRegexMatches(
'/\.depth$/',
'// 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)',
$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.'
)->getProcessedContent();
}
}
15 changes: 12 additions & 3 deletions src/ContentRepository90/Rules/FusionNodeHiddenInIndexRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,29 @@ class FusionNodeHiddenInIndexRector implements FusionRectorInterface

public function getRuleDefinition(): RuleDefinition
{
return CodeSampleLoader::fromFile('Fusion: Rewrite node.hiddenInIndex to node.properties._hiddenInIndex', __CLASS__);
return CodeSampleLoader::fromFile('Fusion: Rewrite node.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/',
'$1.properties._hiddenInIndex',
'$1.property(\'hiddenInIndex\')',
$eelExpression
))
->addCommentsIfRegexMatches(
'/\.hiddenInIndex/',
'// TODO 9.0 migration: Line %LINE: You may need to rewrite "VARIABLE.hiddenInIndex" to VARIABLE.properties._hiddenInIndex. 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 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\')',
$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();
}
}
9 changes: 9 additions & 0 deletions src/ContentRepository90/Rules/FusionNodeIdentifierRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ public function refactorFileContent(string $fileContent): string
->addCommentsIfRegexMatches(
'/\.identifier/',
'// TODO 9.0 migration: Line %LINE: You may need to rewrite "VARIABLE.identifier" to VARIABLE.nodeAggregateId.value. 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\\(\'_identifier\'\\)/',
'$1.nodeAggregateId.value',
$eelExpression
))
->addCommentsIfRegexMatches(
'/\.property\\(\'_identifier\'\\)/',
'// TODO 9.0 migration: Line %LINE: You may need to rewrite "VARIABLE.identifier" to VARIABLE.nodeAggregateId.value. We did not auto-apply this migration because we cannot be sure whether the variable is a Node.'
)->getProcessedContent();
}
}
12 changes: 11 additions & 1 deletion src/ContentRepository90/Rules/FusionNodePathRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ public function refactorFileContent(string $fileContent): string
->addCommentsIfRegexMatches(
'/\.path$/',
'// 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.'
)->getProcessedContent();
)
->process(fn(string $eelExpression) => preg_replace(
'/(node|documentNode|site)\.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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ prototype(Neos.Fusion.Form:Checkbox) < prototype(Neos.Fusion.Form:Component.Fie
#
# pass down props
#
attributes = ${node.contextPath || documentNode.contextPath}
attributes = ${node.contextPath || documentNode.contextPath || node.property('_contextPath') || documentNode.property("_contextPath")}
foo = ${bar.property('_contextPath') || bar.property("_contextPath")}

#
# the `checked` state is calculated outside the renderer to allow` overriding via `attributes`
Expand All @@ -30,15 +31,17 @@ prototype(Neos.Fusion.Form:Checkbox) < prototype(Neos.Fusion.Form:Component.Fie
}
}
-----
// TODO 9.0 migration: Line 26: !! 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 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.
prototype(Neos.Fusion.Form:Checkbox) < prototype(Neos.Fusion.Form:Component.Field) {

renderer = Neos.Fusion:Component {

#
# pass down props
#
attributes = ${Neos.Node.serializedNodeAddress(node) || Neos.Node.serializedNodeAddress(documentNode)}
attributes = ${Neos.Node.serializedNodeAddress(node) || Neos.Node.serializedNodeAddress(documentNode) || Neos.Node.serializedNodeAddress(node) || Neos.Node.serializedNodeAddress(documentNode)}
foo = ${bar.property('_contextPath') || bar.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,7 +5,8 @@ prototype(Neos.Fusion.Form:Checkbox) < prototype(Neos.Fusion.Form:Component.Fie
#
# pass down props
#
attributes = ${node.depth || documentNode.depth}
attributes = ${node.depth || documentNode.depth || node.property('_depth') || documentNode.property("_depth")}
foo = ${bar.property('_depth') || bar.property("_depth")}

#
# the `checked` state is calculated outside the renderer to allow` overriding via `attributes`
Expand All @@ -30,15 +31,17 @@ prototype(Neos.Fusion.Form:Checkbox) < prototype(Neos.Fusion.Form:Component.Fie
}
}
-----
// TODO 9.0 migration: Line 26: 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 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.
prototype(Neos.Fusion.Form:Checkbox) < prototype(Neos.Fusion.Form:Component.Field) {

renderer = Neos.Fusion:Component {

#
# pass down props
#
attributes = ${Neos.Node.depth(node) || Neos.Node.depth(documentNode)}
attributes = ${Neos.Node.depth(node) || Neos.Node.depth(documentNode) || Neos.Node.depth(node) || Neos.Node.depth(documentNode)}
foo = ${bar.property('_depth') || bar.property("_depth")}

#
# 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 @@ -30,15 +30,15 @@ prototype(Neos.Fusion.Form:Checkbox) < prototype(Neos.Fusion.Form:Component.Fie
}
}
-----
// TODO 9.0 migration: Line 26: You may need to rewrite "VARIABLE.hiddenInIndex" to VARIABLE.properties._hiddenInIndex. 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 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.
prototype(Neos.Fusion.Form:Checkbox) < prototype(Neos.Fusion.Form:Component.Field) {

renderer = Neos.Fusion:Component {

#
# pass down props
#
attributes = ${node.properties._hiddenInIndex || documentNode.properties._hiddenInIndex || site.properties._hiddenInIndex}
attributes = ${node.property('hiddenInIndex') || documentNode.property('hiddenInIndex') || site.property('hiddenInIndex')}

#
# 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={node.properties._hiddenInIndex}
name={node.property('hiddenInIndex')}
value={someOtherVariable.hiddenInIndex}
checked={props.checked}
{...node.properties._hiddenInIndex}
{...node.property('hiddenInIndex')}
/>
`
}
Expand Down

0 comments on commit d7c832e

Please sign in to comment.