src/Contao/View/Contao2BackendView/TreePicker.php
protected function generateTreeView($collection, $treeClass)
    {
        $content = [];
        foreach ($collection as $model) {
            /** @var ModelInterface $model */

            $toggleID = $model->getProviderName() . '_' . $treeClass . '_' . $model->getId();

            $content[] = $this->parseModel($model, $toggleID);

            if ($model->getMeta($model::HAS_CHILDREN) && $model->getMeta($model::SHOW_CHILDREN)) {
                $template = new ContaoBackendViewTemplate('widget_treepicker_child');
                $subHtml  = '';

                foreach ($model->getMeta($model::CHILD_COLLECTIONS) as $objChildCollection) {
                    $subHtml .= $this->generateTreeView($objChildCollection, $treeClass);
                }

                $template
                    ->setTranslator($this->getEnvironment()->getTranslator())
                    ->set('objParentModel', $model)
                    ->set('strToggleID', $toggleID)
                    ->set('strHTML', $subHtml)
                    ->set('strTable', $model->getProviderName());

                $content[] = $template->parse();
            }
        }

        return \implode("\n", $content);
    }
protected function generateTreeView($collection, $treeClass)
    {
        $content = [];
        foreach ($collection as $model) {
            /** @var ModelInterface $model */

            $toggleID = $model->getProviderName() . '_' . $treeClass . '_' . $model->getId();

            $content[] = $this->parseModel($model, $toggleID);

            if ($model->getMeta($model::HAS_CHILDREN) && $model->getMeta($model::SHOW_CHILDREN)) {
                $template = new ContaoBackendViewTemplate('widget_treepicker_child');
                $subHtml  = '';

                foreach ($model->getMeta($model::CHILD_COLLECTIONS) as $objChildCollection) {
                    $subHtml .= $this->generateTreeView($objChildCollection, $treeClass);
                }

                $template
                    ->setTranslator($this->getEnvironment()->getTranslator())
                    ->set('objParentModel', $model)
                    ->set('strToggleID', $toggleID)
                    ->set('strHTML', $subHtml)
                    ->set('strTable', $model->getProviderName());

                $content[] = $template->parse();
            }
        }

        return \implode("\n", $content);
    }
protected function generateTreeView ( $ collection , $ treeClass ) { $ content = [ ] ; foreach ( $ collection as $ model ) { /** @var ModelInterface $model */ $ toggleID = $ model -> getProviderName ( ) . '_' . $ treeClass . '_' . $ model -> getId ( ) ; $ content [ ] = $ this -> parseModel ( $ model , $ toggleID ) ; if ( $ model -> getMeta ( $ model :: HAS_CHILDREN ) && $ model -> getMeta ( $ model :: SHOW_CHILDREN ) ) { $ template = new ContaoBackendViewTemplate ( 'widget_treepicker_child' ) ; $ subHtml = '' ; foreach ( $ model -> getMeta ( $ model :: CHILD_COLLECTIONS ) as $ objChildCollection ) { $ subHtml .= $ this -> generateTreeView ( $ objChildCollection , $ treeClass ) ; } $ template -> setTranslator ( $ this -> getEnvironment ( ) -> getTranslator ( ) ) -> set ( 'objParentModel' , $ model ) -> set ( 'strToggleID' , $ toggleID ) -> set ( 'strHTML' , $ subHtml ) -> set ( 'strTable' , $ model -> getProviderName ( ) ) ; $ content [ ] = $ template -> parse ( ) ; } } return \ implode ( "\n" , $ content ) ; }
Generate the tree view for a given collection.

@param CollectionInterface $collection The collection to iterate over.
@param string              $treeClass  The class to use for the tree.

@return string
Generate the tree view for a given collection .