Skip to content
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

!!! TASK: Followup #4520 NodeTypeManager should work on NodeTypeName #4906

Open
wants to merge 3 commits into
base: 9.0
Choose a base branch
from

Conversation

mhsdesign
Copy link
Member

@mhsdesign mhsdesign commented Feb 20, 2024

#4520 (comment)

writing

$nodeTypeManager->getTetheredNodesConfigurationForNodeType($nodeTypeManager->getNodeType($nodeTypeName))

feels not right, the nodeTypeManger should just operate on NodeTypeNames
(...but we can also allow NodeType instances either way ...)

Upgrade instructions

From 8.3

- $nodeType->getAutoCreatedChildNodes();
+ $nodeTypeManager->getTetheredNodesConfigurationForNodeType($nodeType->name);

- $nodeType->hasAutoCreatedChildNode($nodeName);
+ $nodeType->hasTetheredNode($nodeName);

- $parentsNodeType->getTypeOfAutoCreatedChildNode($nodeName)->name;
+ $parentsNodeType->getNodeTypeNameOfTetheredNode($nodeName);

- $parentsNodeType->getTypeOfAutoCreatedChildNode($nodeName);
+ $nodeTypeManager->getTypeOfTetheredNode($parentsNodeType->name, $nodeName);

- $grandParentsNodeType->allowsGrandchildNodeType($parentNodeName->value, $nodeType);
+ $nodeTypeManager->isNodeTypeAllowedAsChildToTetheredNode($grandParentsNodeType->name, $parentNodeName, $nodeType->name);

From 9.x-dev

- $nodeTypeManager->getTetheredNodesConfigurationForNodeType($nodeType);
+ $nodeTypeManager->getTetheredNodesConfigurationForNodeType($nodeType->name);

- $nodeTypeManager->getTypeOfTetheredNode($parentsNodeType, $nodeName);
+ $nodeTypeManager->getTypeOfTetheredNode($parentsNodeType->name, $nodeName);

- $nodeTypeManager->isNodeTypeAllowedAsChildToTetheredNode($grandParentsNodeType, $parentNodeName, $nodeType);
+ $nodeTypeManager->isNodeTypeAllowedAsChildToTetheredNode($grandParentsNodeType->name, $parentNodeName, $nodeType->name);

Review instructions

Rector migrations will be provided as part of neos/rector#57

Checklist

  • Code follows the PSR-2 coding style
  • Tests have been created, run and adjusted as needed
  • The PR is created against the lowest maintained branch
  • Reviewer - PR Title is brief but complete and starts with FEATURE|TASK|BUGFIX
  • Reviewer - The first section explains the change briefly for change-logs
  • Reviewer - Breaking Changes are marked with !!! and have upgrade-instructions

@github-actions github-actions bot added the 9.0 label Feb 20, 2024
@mhsdesign
Copy link
Member Author

As alternative trick we can as well make these hardcore mehtods internal like who really understands isNodeTypeAllowedAsChildToTetheredNode ?? :D Usages are limited to Neos.Neos and FlowpackNodeTemplates

@mhsdesign mhsdesign force-pushed the task/followup-4520-nodeTypeManger branch from 8dfe476 to e224d4a Compare April 3, 2024 19:28
@mhsdesign mhsdesign changed the title task/followup-4520-nodeTypeManger TASK: Followup #4520 nodeTypeManger Apr 3, 2024
@github-actions github-actions bot added the Task label Apr 3, 2024
@mhsdesign mhsdesign changed the title TASK: Followup #4520 nodeTypeManger !!! TASK: Followup #4520 NodeTypeManager should work on NodeTypeName Apr 3, 2024
@mhsdesign mhsdesign marked this pull request as ready for review April 3, 2024 19:31
@mhsdesign
Copy link
Member Author

Todo these rector migration would need to be adjusted so they dont pass the $nodeType to the methods, but $nodeType->name:

  • NodeTypeGetAutoCreatedChildNodesRector
  • NodeTypeGetTypeOfAutoCreatedChildNodeRector
  • NodeTypeAllowsGrandchildNodeTypeRector

@mhsdesign
Copy link
Member Author

@bwaidelich as you also currently refactor the NodeTypeManager (#4999) ... do you think we should also incorporate this change (i yet have to fix ci but just want to know if its worth the effort)

@bwaidelich
Copy link
Member

do you think we should also incorporate this change

We'll have to since Node::nodeType will most probably be removed

Copy link
Contributor

@dlubitz dlubitz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good in general. I stumled over the method names. Should we change them as we changed the parameter from NodeType to NodeTypeName?

E.g:
isNodeTypeAllowedAsChildToTetheredNode =>isNodeTypeNameAllowedAsChildToTetheredNode

* @return bool true if the $nodeType is allowed as grandchild node, false otherwise.
* @throws \InvalidArgumentException if the requested tethered node is not configured in the parent NodeType. Check via {@see NodeType::hasTetheredNode()}.
*/
public function isNodeTypeAllowedAsChildToTetheredNode(NodeType $parentNodeType, NodeName $tetheredNodeName, NodeType $nodeType): bool
public function isNodeTypeAllowedAsChildToTetheredNode(NodeTypeName $parentNodeTypeName, NodeName $tetheredNodeName, NodeTypeName $nodeTypeName): bool
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 3rd param should probably be rather $nodeTypeNameInQuestion or sth

@mhsdesign
Copy link
Member Author

Should we change them as we changed the parameter from NodeType to NodeTypeName?

good point but i dont think so as the thing the user of the api tries to solve if a NodeType is allowed or not ... that the node type is identified via NodeTypeName can be left out in the method name i think.


Another thing i just remembered is that we want to be rather forgiving (see #4954) so i dont know if all the new requireNodeType call would do us good or if they would be a pita in the future. Have to think if it makes sense to return false for booleans or just null otherwise.

@bwaidelich
Copy link
Member

isNodeTypeAllowedAsChildToTetheredNode =>isNodeTypeNameAllowedAsChildToTetheredNode

That doesn't make sense to me. Yes, we pass in a node name but this method is about the allowed node type

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants