private function recurseLinkNodes(array $nodes, $language, $mode, TreeNodeInterface $targetNode = null)
    {
        $elementService = $this->get('phlexible_element.element_service');
        $iconResolver = $this->get('phlexible_element.icon_resolver');

        $data = [];

        foreach ($nodes as $node) {
            /* @var $node \Phlexible\Bundle\TreeBundle\Model\TreeNodeInterface */

            $element = $elementService->findElement($node->getTypeId());
            $elementVersion = $elementService->findLatestElementVersion($element);
            $elementtype = $elementService->findElementtype($element);

            $tid = $node->getId();
            $tree = $node->getTree();
            $children = $tree->getChildren($node);

            $dataNode = [
                'id' => $node->getId(),
                'eid' => $node->getTypeId(),
                'text' => $elementVersion->getBackendTitle($language, $element->getMasterLanguage()).' ['.$tid.']',
                'icon' => $iconResolver->resolveTreeNode($node, $language),
                'children' => !$tree->hasChildren($node)
                    ? []
                    : $mode === self::MODE_NOET_TARGET && $tree->isParentOf($node, $targetNode)
                        ? $this->recurseLinkNodes($children, $language, $mode, $targetNode)
                        : false,
                'leaf' => !$tree->hasChildren($node),
                'expanded' => false,
            ];

            /*
            $leafCount = 0;
            if (is_array($dataNode['children']))
            {
                foreach($dataNode['children'] as $child)
                {
                    $leafCount += $child['leafCount'];
                    if (!isset($child['disabled']) || !$child['disabled'])
                    {
                        ++$leafCount;
                    }
                }
            }
            $dataNode['leafCount'] = $leafCount;
            */

            $data[] = $dataNode;
        }

        return $data;
    }
private function recurseLinkNodes(array $nodes, $language, $mode, TreeNodeInterface $targetNode = null)
    {
        $elementService = $this->get('phlexible_element.element_service');
        $iconResolver = $this->get('phlexible_element.icon_resolver');

        $data = [];

        foreach ($nodes as $node) {
            /* @var $node \Phlexible\Bundle\TreeBundle\Model\TreeNodeInterface */

            $element = $elementService->findElement($node->getTypeId());
            $elementVersion = $elementService->findLatestElementVersion($element);
            $elementtype = $elementService->findElementtype($element);

            $tid = $node->getId();
            $tree = $node->getTree();
            $children = $tree->getChildren($node);

            $dataNode = [
                'id' => $node->getId(),
                'eid' => $node->getTypeId(),
                'text' => $elementVersion->getBackendTitle($language, $element->getMasterLanguage()).' ['.$tid.']',
                'icon' => $iconResolver->resolveTreeNode($node, $language),
                'children' => !$tree->hasChildren($node)
                    ? []
                    : $mode === self::MODE_NOET_TARGET && $tree->isParentOf($node, $targetNode)
                        ? $this->recurseLinkNodes($children, $language, $mode, $targetNode)
                        : false,
                'leaf' => !$tree->hasChildren($node),
                'expanded' => false,
            ];

            /*
            $leafCount = 0;
            if (is_array($dataNode['children']))
            {
                foreach($dataNode['children'] as $child)
                {
                    $leafCount += $child['leafCount'];
                    if (!isset($child['disabled']) || !$child['disabled'])
                    {
                        ++$leafCount;
                    }
                }
            }
            $dataNode['leafCount'] = $leafCount;
            */

            $data[] = $dataNode;
        }

        return $data;
    }
private function recurseLinkNodes ( array $ nodes , $ language , $ mode , TreeNodeInterface $ targetNode = null ) { $ elementService = $ this -> get ( 'phlexible_element.element_service' ) ; $ iconResolver = $ this -> get ( 'phlexible_element.icon_resolver' ) ; $ data = [ ] ; foreach ( $ nodes as $ node ) { /* @var $node \Phlexible\Bundle\TreeBundle\Model\TreeNodeInterface */ $ element = $ elementService -> findElement ( $ node -> getTypeId ( ) ) ; $ elementVersion = $ elementService -> findLatestElementVersion ( $ element ) ; $ elementtype = $ elementService -> findElementtype ( $ element ) ; $ tid = $ node -> getId ( ) ; $ tree = $ node -> getTree ( ) ; $ children = $ tree -> getChildren ( $ node ) ; $ dataNode = [ 'id' => $ node -> getId ( ) , 'eid' => $ node -> getTypeId ( ) , 'text' => $ elementVersion -> getBackendTitle ( $ language , $ element -> getMasterLanguage ( ) ) . ' [' . $ tid . ']' , 'icon' => $ iconResolver -> resolveTreeNode ( $ node , $ language ) , 'children' => ! $ tree -> hasChildren ( $ node ) ? [ ] : $ mode === self :: MODE_NOET_TARGET && $ tree -> isParentOf ( $ node , $ targetNode ) ? $ this -> recurseLinkNodes ( $ children , $ language , $ mode , $ targetNode ) : false , 'leaf' => ! $ tree -> hasChildren ( $ node ) , 'expanded' => false , ] ; /*
            $leafCount = 0;
            if (is_array($dataNode['children']))
            {
                foreach($dataNode['children'] as $child)
                {
                    $leafCount += $child['leafCount'];
                    if (!isset($child['disabled']) || !$child['disabled'])
                    {
                        ++$leafCount;
                    }
                }
            }
            $dataNode['leafCount'] = $leafCount;
            */ $ data [ ] = $ dataNode ; } return $ data ; }
Recurse over tree nodes.

@param array             $nodes
@param string            $language
@param int               $mode
@param TreeNodeInterface $targetNode

@return array
Recurse over tree nodes .