Tree icon indicating copy to clipboard operation
Tree copied to clipboard

Unable to check if parent is valid when using custom build warning callback

Open Pnoexz opened this issue 6 years ago • 3 comments

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.

Pnoexz avatar Dec 18 '19 17:12 Pnoexz

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.

BlueM avatar Oct 03 '24 14:10 BlueM

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

Pnoexz avatar Oct 03 '24 15:10 Pnoexz

Thanks for the speedy reply. Then the code will pass $this.

BlueM avatar Oct 03 '24 15:10 BlueM