コード例 #1
0
ファイル: Tree.php プロジェクト: nayjest/tree
 /**
  * Builds tree based on its nodes registry and hierarchy configuration
  * if structure update required.
  */
 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();
             }
         }
     }
 }
コード例 #2
0
ファイル: ChildNodeTrait.php プロジェクト: nayjest/tree
 private function checkParentRelation(ParentNodeInterface $parent = null)
 {
     if ($parent === null) {
         throw new NoParentException();
     }
     if (!$parent->isWritable()) {
         throw new ReadonlyNodeModifyException();
     }
     if ($this->isLocked()) {
         throw new LockedNodeException();
     }
 }