protected function createValueOptions(NodeInterface $node, $allowSelectNodes = false, $isRoot=true)
    {
        $key    = $isRoot ? $node->getValue() : $node->getValueWithParents();
        $name   = $node->getName();

        if ($node->hasChildren()) {
            $leafOptions = [];

            if ($allowSelectNodes && !$isRoot) {
                $leafOptions[$key] = $name;
                $key = "$key-group";
            }

            foreach ($node->getChildren() as $child) {
                $leafOptions += $this->createValueOptions($child, $allowSelectNodes, false);
            }

            $value = [
                'label' => $name,
                'options' => $leafOptions
            ];
        } else {
            $value = $name;
        }

        return [$key => $value];
    }
protected function createValueOptions(NodeInterface $node, $allowSelectNodes = false, $isRoot=true)
    {
        $key    = $isRoot ? $node->getValue() : $node->getValueWithParents();
        $name   = $node->getName();

        if ($node->hasChildren()) {
            $leafOptions = [];

            if ($allowSelectNodes && !$isRoot) {
                $leafOptions[$key] = $name;
                $key = "$key-group";
            }

            foreach ($node->getChildren() as $child) {
                $leafOptions += $this->createValueOptions($child, $allowSelectNodes, false);
            }

            $value = [
                'label' => $name,
                'options' => $leafOptions
            ];
        } else {
            $value = $name;
        }

        return [$key => $value];
    }
protected function createValueOptions ( NodeInterface $ node , $ allowSelectNodes = false , $ isRoot = true ) { $ key = $ isRoot ? $ node -> getValue ( ) : $ node -> getValueWithParents ( ) ; $ name = $ node -> getName ( ) ; if ( $ node -> hasChildren ( ) ) { $ leafOptions = [ ] ; if ( $ allowSelectNodes && ! $ isRoot ) { $ leafOptions [ $ key ] = $ name ; $ key = "$key-group" ; } foreach ( $ node -> getChildren ( ) as $ child ) { $ leafOptions += $ this -> createValueOptions ( $ child , $ allowSelectNodes , false ) ; } $ value = [ 'label' => $ name , 'options' => $ leafOptions ] ; } else { $ value = $ name ; } return [ $ key => $ value ] ; }
Create value options from a node.

@param NodeInterface $node
@param bool $allowSelectNodes
@param bool $isRoot

@return array
Create value options from a node .