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: Remove NodeTypeManager from NodeType #4520

Merged

Conversation

kitsunet
Copy link
Member

@kitsunet kitsunet commented Sep 15, 2023

Disentangle NodeTypeManager from NodeType.

Upgrade instructions

This is breaking because it removes API methods on the NodeType. If you previously used one of:

  • getAutoCreatedChildNodes
  • hasAutoCreatedChildNode
  • getTypeOfAutoCreatedChildNode
  • allowsGrandchildNodeType

the NodeTypeManager can provide replacements:

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

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

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

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

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

Resolves: #4515
Resolves: #4570

Disentangle NodeTypeManager from NodeType.

This is breaking because it removes API methods.

Resolves: neos#4515
@github-actions github-actions bot added the 9.0 label Sep 15, 2023
@kitsunet
Copy link
Member Author

kitsunet commented Sep 15, 2023

Silly me, after removing everything that uses it I forgot to remove the actual dependency.... will push an update to that effect.

* @param array<string,mixed> $constraints
*/
public function __construct(
private readonly array $constraints
Copy link
Member Author

Choose a reason for hiding this comment

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

Would be neat to have this be a DTO with the constraints configuration.

Copy link
Member

Choose a reason for hiding this comment

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

yes or at lest an example how this looks would be cool ^^

Copy link
Member

Choose a reason for hiding this comment

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

+1 for DTO
Also there seem to be some overlaps with the NodeTypeConstraints DTO

@mhsdesign
Copy link
Member

@kitsunet i did adjust two minor things as discussed in slack in your branch, i hope that was okay ^^

@kitsunet
Copy link
Member Author

@kitsunet i did adjust two minor things as discussed in slack in your branch, i hope that was okay ^^

Of course, good stuff

@kitsunet
Copy link
Member Author

I just realize also @bwaidelich how would we rector this, given that we would need to insure you have a nodeTypeManager available to you?

@mhsdesign
Copy link
Member

Hmmm ... id nearly argue that the few times people from outside use getAutoCreatedChildNodes its not worth to write a migration for.

For example there are 0 migrations for anything more complex. Every person with a custom importer / exporter most likely has to rewrite it. Even Node::setProperty has no migration.

The rector migrations are mostly currently for simple read operations.

So bevor migrating the dilemma getAutoCreatedChildNodes ^^ i would say we tackle more important migrations?

@kitsunet
Copy link
Member Author

I would perfectly agree, I thought @bwaidelich saw this as condition for this change? Anyways, will fix the linter problems and then this should be good to go...

@kitsunet kitsunet marked this pull request as ready for review September 17, 2023 13:53
@kitsunet
Copy link
Member Author

neos/neos-ui#3621 Adaption of UI

@kitsunet
Copy link
Member Author

kitsunet commented Sep 17, 2023

Wait why does my exception class need an internal or api annotation? (see linter error)

@bwaidelich
Copy link
Member

how would we rector this

There are similar cases where we add injection code for the CR registry

I thought @bwaidelich saw this as condition for this change?

No, that was a different one (context.inBackend). I'd still love some migrations but only if it's not too much work ofc

why does my exception class need an api or internal annotation?

@skurfuerst added this rule IIRC so that we explicitly put all core classes into one of the two buckets. I think it's a great idea.
If the new exception is expected to be handled in userland code, it should be api IMO

@kitsunet
Copy link
Member Author

Right but how I understand it and how I adjusted the code, you would need a CR registry and build the code to get to a CR id from which then you can get the respective NodeTypeManager? If it was just a simple inject for NodeTypeManager sure, that should be doable.

@mhsdesign
Copy link
Member

@kitsunet yes and this is clearly impossible to adjust for every case like:

function something(NodeType $nt) {
  $nt->getAutoCreatedChildNodes();
}

@mhsdesign
Copy link
Member

Hi ;) I have two little things:

just as info:

the method getNodeTypeNameOfAutoCreatedChildNode has a bug #4344 and a bugfix is on its way but ill recreated it #4482 -> tldr; we cannot do isset($this->fullConfiguration['childNodes'][$nodeName->value]['type']) as we first need to transliterate the keys childNodes of the original configuration.


Im also wondering since the allowsGrandchildNodeType method is gone if this method should stay here in this place?
Its also not often used in userland.


I also noticed once, that the method namings allowsGrandchildNodeType and allowsChildNode might not fit anymore our current naming schema. (See command handling where we rather use wordings like areNodeTypeConstraintsImposedByGrandparentValid areNodeTypeConstraintsImposedByParentValid)

So when we already move the methods around the whole world we might also rename them to fit better? What do you say @skurfuerst maybe that was your intention when writing those "wrapper" methods?

@bwaidelich
Copy link
Member

you would need a CR registry and build the code to get to a CR id from which then you can get the respective NodeTypeManager?

For migrations from older versions (where there was only a single CR) we just use the default CR

this is clearly impossible to adjust for every case like [...]

But this is what rector is for, isn't it?
We do similar things already, see for example: https://github.com/neos/rector/blob/main/tests/ContentRepository90/Rules/ContentDimensionCombinatorGetAllAllowedCombinationsRector/Fixture/some_class.php.inc

Copy link
Member

@bwaidelich bwaidelich left a comment

Choose a reason for hiding this comment

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

This is great already, thanks for the effort!
Just a couple of comments after first quick review

@bwaidelich
Copy link
Member

@kitsunet just checking: do you still plan to work on this one for the beta1 or shall we try to find someone to take over?

(the migration topic can be skipped of course, we can always add it later if we find the time)

@mhsdesign
Copy link
Member

@bwaidelich what do you say about my comment above?

Im also wondering since the allowsGrandchildNodeType method is gone if this method should stay here in this place?
Its also not often used in userland.

I also noticed once, that the method namings allowsGrandchildNodeType and allowsChildNode might not fit anymore our current naming schema. (See command handling where we rather use wordings like areNodeTypeConstraintsImposedByGrandparentValid areNodeTypeConstraintsImposedByParentValid)

So when we already move the methods around the whole world we might also rename them to fit better?

Copy link
Member

@bwaidelich bwaidelich left a comment

Choose a reason for hiding this comment

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

Some more inline comments.

And @mhsdesign:

Im also wondering since the allowsGrandchildNodeType method is gone if this method should stay here in this place?
Its also not often used in userland.

I don't really understand which method you refer to and what you suggest to replace it with

And re

I also noticed once, that the method namings allowsGrandchildNodeType and allowsChildNode might not fit anymore our current naming schema

I agree, but "areNodeTypeConstraintsImposedByGrandparentValid" is a mouthful and not also leaves room for interpretation.

Maybe we should look at the using code again and rethink what we want to evaluate in order to find a better name

* @param array<string,mixed> $constraints
*/
public function __construct(
private readonly array $constraints
Copy link
Member

Choose a reason for hiding this comment

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

+1 for DTO
Also there seem to be some overlaps with the NodeTypeConstraints DTO

@kitsunet
Copy link
Member Author

Hi ;) I have two little things:

just as info:

the method getNodeTypeNameOfAutoCreatedChildNode has a bug #4344 and a bugfix is on its way but ill recreated it #4482 -> tldr; we cannot do isset($this->fullConfiguration['childNodes'][$nodeName->value]['type']) as we first need to transliterate the keys childNodes of the original configuration.

Im also wondering since the allowsGrandchildNodeType method is gone if this method should stay here in this place? Its also not often used in userland.

I am not married to leaving it there, but it is genuinly information the nodetype has, so it felt alright to have it in there, despite everything else being "displaced" now.

@bwaidelich I will continue :) But if anyone wants to do something feel free.

@mhsdesign
Copy link
Member

mhsdesign commented Sep 23, 2023

Sorry @bwaidelich I accidentally omitted the key word for understanding my comment

Im also wondering since the allowsGrandchildNodeType method is gone if this method should stay here in this place?
Its also not often used in userland.

I don't really understand which method you refer to and what you suggest to replace it with

I’m referring to the allowsChildNode method, and thought about moving it too to the nodetype manager to have the two methods at one place.(also the allowsChildNode has some complexity and I thought we wanted to make the nodetype less complex)

@kitsunet
Copy link
Member Author

kitsunet commented Oct 9, 2023

Sooo did you two discuss this further or can we do that this week?

@mhsdesign
Copy link
Member

no lets discuss our big plan for the nodeType/Manager cleanups ^^ i think @bwaidelich continued already a bit with his other pr.

@kitsunet
Copy link
Member Author

Collecting some open questions we should deal with and then get this merged:

  • getAutoCreatedChildNodesFor vs getAutoCreatedChildNodesForNodeType
  • remaining methods in NodeType, do we want to move them to the NodeTypeManager (where else), to me seems to make the NTM even more "godlike", and the information the methods provides is naturally in the NodeType anyways, so I would like to keep it the way it is now
  • renaming childNode stuff to tetheredNode stuff ?

@mhsdesign
Copy link
Member

thanks for the summary, my opinion would be

  1. use getAutoCreatedChildNodesForNodeType as described above
  2. the method NodeType::allowsChildNode should stay as is, as you argued. Further discussions of the "meta" topic whether we want to strip down the nodeType any further should not block this pr -> there are definitely points we might consider like the implicit object manager dependency when using new for the post-processors. Turn NodeType into a less magic self-translating, lazy-loading beast -> readonly immutable #4523
  3. this is indeed closely related and i made a separate issue !!! NodeType rename autoCreated naming to tethered #4570
    but i would be fine to address the naming in another pr - with one downside: we will also rename your newly introduced getTypeOfAutoCreatedChildNode again and thats kind of smelly as the upgrade instructions here would be outdated.

@kitsunet
Copy link
Member Author

I think in that case lets put the renaming in here so it's a single breaking change for those.

@kitsunet
Copy link
Member Author

kitsunet commented Oct 13, 2023

UI change is up to date with the latest changes.

@mhsdesign mhsdesign self-requested a review October 16, 2023 09:37
@mhsdesign
Copy link
Member

Thank you so much for adjusting this and fixing the tests ❤️ I assume this is now ready for a final review?

@kitsunet
Copy link
Member Author

Yep all ready from my side :)

Copy link
Member

@nezaniel nezaniel left a comment

Choose a reason for hiding this comment

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

Fine by me

Copy link
Member

@mhsdesign mhsdesign left a comment

Choose a reason for hiding this comment

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

Thank you for taking care and also adjusting the naming to tethered ❤️

I ran the e2e tests locally of the ui and they succeed and also the neos demo runs fine.

Additionally i had a look at your latest rename adjustments and can only approve ;)

FYI: Neos ui part: neos/neos-ui#3642

@mhsdesign mhsdesign mentioned this pull request Oct 17, 2023
9 tasks
@mhsdesign mhsdesign merged commit f04a914 into neos:9.0 Oct 17, 2023
8 checks passed
@mhsdesign
Copy link
Member

Hmm im just wondering if we should allow a union here of NodeType|NodeTypeName.

otherwise one might need to write this, which feels odd doesnt it?

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

@kitsunet kitsunet deleted the task/90-remove-nodetypemanager-from-node-4515 branch February 13, 2024 08:35
mhsdesign added a commit to mhsdesign/neos-development-collection that referenced this pull request Apr 3, 2024
mhsdesign added a commit to mhsdesign/neos-development-collection that referenced this pull request May 1, 2024
mhsdesign added a commit to mhsdesign/neos-development-collection that referenced this pull request May 13, 2024
mhsdesign added a commit to mhsdesign/neos-development-collection that referenced this pull request May 14, 2024
kitsunet added a commit that referenced this pull request May 17, 2024
…nger

!!! TASK: Followup #4520 Introduce `NodeType::tetheredNodeTypeDefinitions`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

!!! NodeType rename autoCreated naming to tethered !!! TASK: Remove NodeTypeManager from NodeType
4 participants