src/Tree.php
public function build()
    {
        if ($this->updateRequired) {
            $this->updateRequired = false;
            foreach ($this->nodes as $node) {
                if ($node->parent()) {
                    $node->unlock()->detach();
                }
            }
            $this->root->addChildren($this->builder->build($this->hierarchy, $this->nodes->toArray()));
            foreach ($this->nodes as $node) {
                if ($node->parent() === $this->root || $this->nodes->contains($node->parent())) {
                    $node->lock();
                }
            }
        }
    }
public function build()
    {
        if ($this->updateRequired) {
            $this->updateRequired = false;
            foreach ($this->nodes as $node) {
                if ($node->parent()) {
                    $node->unlock()->detach();
                }
            }
            $this->root->addChildren($this->builder->build($this->hierarchy, $this->nodes->toArray()));
            foreach ($this->nodes as $node) {
                if ($node->parent() === $this->root || $this->nodes->contains($node->parent())) {
                    $node->lock();
                }
            }
        }
    }
public function build ( ) { if ( $ this -> updateRequired ) { $ this -> updateRequired = false ; foreach ( $ this -> nodes as $ node ) { if ( $ node -> parent ( ) ) { $ node -> unlock ( ) -> detach ( ) ; } } $ this -> root -> addChildren ( $ this -> builder -> build ( $ this -> hierarchy , $ this -> nodes -> toArray ( ) ) ) ; foreach ( $ this -> nodes as $ node ) { if ( $ node -> parent ( ) === $ this -> root || $ this -> nodes -> contains ( $ node -> parent ( ) ) ) { $ node -> lock ( ) ; } } } }
Builds tree based on its nodes registry and hierarchy configuration
if structure update required.
Builds tree based on its nodes registry and hierarchy configuration if structure update required .