User tests: Successful: Unsuccessful:
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.
Status | New | ⇒ | Pending |
Category | ⇒ | Libraries |
Labels |
Added:
?
|
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()
is a rather simple thing and a similar thing does exist in most other tree oriented packages I work with.
getRoot has been added. Can we simply merge this or do we need "testers"?
Status | Pending | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2019-01-04 15:45:08 |
Closed_By | ⇒ | rdeutz |
looks good me, maybe a getRoot function could make sense