Closed TomDeSmet closed 2 years ago
Yeah, the problem is that toArray()
only converts properties of a node element, not methods. For example, there's no active
or target
properties, but there's getActive()
and getTarget()
, which through PHP's magic __get()
methods they can be callable by active
or getActive()
.
We also need to return a collection of arrays here, because we're adding children
which doesn't exist as a property.
Should be added for the next release. To get this early, change your verbb/navigation
requirement in composer.json
to:
"require": {
"verbb/navigation": "dev-craft-4 as 2.0.0",
"...": "..."
}
Then run composer update
.
Added in 2.0.1
Description Every node has an
active
property but it isn't added to the array when getting the data from thetree()
function. I tried debugging and noticed this in theNavs.php
buildNavTree()
function. In the forEach there, if you trace$node->active
it returnstrue
orfalse
. Than there's this line:$nodeTree[$key] = $node->toArray();
If I trace$nodeTree[$key]["active"]
it errors because theactive
property is not in the array. Why did it get removed?The same with
target
for example. It would be so nice to have all those node properties inside that function! Because than we have everything straight away to build our nav in Vue, instead of needing to create a custom data object in twig or a PHP function.Additional info