-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
[4.0] Adding a node object interface #23364
Conversation
looks good me, maybe a getRoot function could make sense |
Adding a getRoot method would mean that the objects need to know about the whole tree and not just their direct children and their parent. I'd like to keep it as simple as possible and each node by default would only need to know the bare minimum. |
ok, then you have to use getParent() so often till you not get a parent. Is also a way to go. |
public function getRoot(): object
{
$root = $this->getParent();
if (!$root) {
return $this;
}
while ($root->getParent()) {
$root = $root->getParent();
}
return $root;
} |
So, is the consensus that you want such a getRoot method? I personally would want to keep it rather simple and leave such methods out which can be created with the other methods of the interface. But in any case, just say which way to go and I'll adapt it. It would just be nice to move forward with this. |
Personally I'd say add it, |
getRoot has been added. Can we simply merge this or do we need "testers"? |
This adds an interface for node objects. For now this only adds the interface, but these are supposed to be applied to CategoriesNode, MenuItem and a class for tags in the future. And of course wherever else they would fit.