neos / neos-development-collection

The unified repository containing the Neos core packages, used for Neos development.
https://www.neos.io/
GNU General Public License v3.0
260 stars 221 forks source link

!!! TASK: Remove `Node::nodeType` #5021

Closed mhsdesign closed 2 weeks ago

mhsdesign commented 2 months ago

~Requires https://github.com/neos/neos-development-collection/pull/5020 in the long term~

With https://github.com/neos/neos-development-collection/pull/4466 the fallback NodeType handling was removed from the core NodeType manager and extracted to Neos. See the trait NodeTypeWithFallbackProvider. That required to make the nodeType field nullable on the NodeType.

This pr takes it a bit further by fully removing the attached NodeType schema from the Node. The Node attached NodeType was declared as deprecated with Neos9-Beta10.

Resolves: #5019

Upgrade instructions

In Fusion accessing the NodeType via ${node.nodeType} wont work longer but one can leverage the helper ${Neos.Node.getNodeType(node)} to access the NodeType.

To get the NodeType for a Node in PHP, one can either use the Node::nodeTypeName and ask the Neos\ContentRepository\Core\NodeType\NodeTypeManager::getNodeType:

+ $nodeTypeManager->getNodeType($node->nodeTypeName);
- $node->nodeType;

For just accessing the string of the NodeType name you can consult the Node directly:

- $node->getNodeType()->getName();
+ $node->nodeTypeName->value;

Also note that getNodeType was made nullable by removing the default fallback. change To restore this behaviour you can use the Neos\Neos\Utility\NodeTypeWithFallbackProvider trait which will return a NodeType instance for any Node considering the Fallback (the Neos.Neos:FallbackNode) in case the requested NodeType was removed. Please note that this behaviour is discouraged in favour of using nullable NodeTypes:

+ #[Flow\Inject]
+ protected ContentRepositoryRegistry $contentRepositoryRegistry;
+
+ use NodeTypeWithFallbackProvider;
+
+ $this->getNodeType($node);
- $node->nodeType;

Review instructions

Followup node.nodeType viewhelper for fluid (see also https://github.com/neos/neos-development-collection/issues/5023) Rector migrations will be provided as part of https://github.com/neos/rector/issues/57

Checklist

pKallert commented 2 weeks ago

The nodetype is also still used in https://github.com/neos/neos-development-collection/blob/9.0/Neos.Neos/Tests/Functional/Fusion/NodeHelperTest.php#L93. I am not sure if this is relevant here, since the tests seem to run through? Could at least be worth looking at :)

mhsdesign commented 2 weeks ago

Thanks for your throughout review @pKallert the NodeHelperTest must be rewritten to behat at some point see comment:

Skipped. Either migrate to behat or find a better way to mock node read models. See https://github.com/neos/neos-development-collection/issues/4317