Unable to check if parent is valid when using custom build warning callback
When encountering a build issue, I want to log an error instead of throwing an exception because the rest of the tree is still usable. The default handler checks if a parent is valid by using $this->nodes which is not available or passed to the callback at build time.
Admittedly – it’s embarrassing to react to this issue after almost five years. (Maybe you know that yourself: once something’s at the bottom of the inbox, it’s at the bottom of the inbox …)
Anyways, I am working on an improved version of the library, which hopefully fulfills everyone’s need. I do understand why you wish to have access to the nodes, but: wouldn’t it be more flexible to pass the Tree instance? In the callable, you could still use $tree->getNodes() to get all the nodes, but also do everything else, like getting root nodes.
It's all good, coding and maintaining a public library is time consuming. I don't even remember which project I was using this library for, and I likely ended up using my fork instead. Looking back at the code and my PR, it might be better passing $this instead, but I don't know how it would behave since this is all happening in the constructor
Thanks for the speedy reply. Then the code will pass $this.