Move this node under another node.

@param Node $newParent The new parent node

@throws MoveException throws a MoveException in case of errors
502410
public function move(Node $newParent)
    {
        $error = $this->checkMove($newParent);
        if ($error !== null) {
            throw $error;
        }
        if ($this->getTreeNodeParentID() != $newParent->getTreeNodeID()) {
            $db = Database::connection();
            $existingDisplayOrder = $this->treeNodeDisplayOrder;
            $treeNodeDisplayOrder = (int) $db->fetchColumn('select count(treeNodeDisplayOrder) from TreeNodes where treeNodeParentID = ?', [$newParent->getTreeNodeID()]);
            $db->executeQuery('update TreeNodes set treeNodeParentID = ?, treeNodeDisplayOrder = ? where treeNodeID = ?', [$newParent->getTreeNodeID(), $treeNodeDisplayOrder, $this->treeNodeID]);
            if (!$this->overrideParentTreeNodePermissions()) {
                $db->executeQuery('update TreeNodes set inheritPermissionsFromTreeNodeID = ? where treeNodeID = ?', [$newParent->getTreeNodePermissionsNodeID(), $this->treeNodeID]);
            }
            $oldParent = $this->getTreeNodeParentObject();
            if (is_object($oldParent)) {
                // Instead of just rescanning all the nodes (which could take a long time),
                // let's just update all the nodes with display order above this one to be their current
                // order - 1
                $db->executeQuery(
                    'update TreeNodes set treeNodeDisplayOrder = (treeNodeDisplayOrder - 1) 
where treeNodeDisplayOrder > ? and treeNodeParentID = ?',
                    [$existingDisplayOrder, $oldParent->getTreeNodeID()]
                );
                //$oldParent->rescanChildrenDisplayOrder();
                $oldParent->updateDateModified();
            }
            $newParent->updateDateModified();
            $this->treeNodeParentID = $newParent->getTreeNodeID();
            $this->treeNodeDisplayOrder = $treeNodeDisplayOrder;
        }
    }
211602
def move(self, newX1) :
		""""""
		if self.x1 != None and self.x2 != None :
			offset = newX1-self.x1
			aux_moveTree(offset, self)
		elif len(self.children) > 0 :
			offset = newX1-self.children[0].x1
			aux_moveTree(offset, self)
1250732
public function replaceChild(int $childId, AbstractNode $newChild): void
    {
        $oldChild = $this->children[$childId];

        $newChild->prev = $oldChild['prev'];
        $newChild->next = $oldChild['next'];

        $keys = array_keys($this->children);
        $index = array_search($childId, $keys, true);
        $keys[$index] = $newChild->id();
        $this->children = array_combine($keys, $this->children);
        $this->children[$newChild->id()] = array(
            'prev' => $oldChild['prev'],
            'node' => $newChild,
            'next' => $oldChild['next']
        );

        // chnge previous child id to new child
        if ($oldChild['prev'] && isset($this->children[$newChild->prev])) {
            $this->children[$oldChild['prev']]['next'] = $newChild->id();
        }

        // change next child id to new child
        if ($oldChild['next'] && isset($this->children[$newChild->next])) {
            $this->children[$oldChild['next']]['prev'] = $newChild->id();
        }
        
        // remove old child
        unset($this->children[$childId]);

        // clean out cache
        $this->clear();
    }
1335853
protected function moveNode(Node\NodeInterface $item, $moveLeft, $moveRight, $moveLevel)
	{
//		$newLeft = $item->getLeftValue() + (int) $moveLeft;
//		$newRight = $item->getRightValue() + (int) $moveRight;
//		$newLevel = $item->getLevel() + (int) $moveLevel;
//
// Call original local move method for items not in the database yet
		parent::moveNode($item, $moveLeft, $moveRight, $moveLevel);

// In case of entity update, make the new nested set values to be ignored
		$insert = $this->entityManager->getUnitOfWork()->isScheduledForInsert($item);
		if ( ! $insert) {
			$oid = spl_object_hash($item);
			$this->entityManager->getUnitOfWork()->setOriginalEntityProperty($oid, 'level', $item->getLevel());
			$this->entityManager->getUnitOfWork()->setOriginalEntityProperty($oid, 'right', $item->getRightValue());
			$this->entityManager->getUnitOfWork()->setOriginalEntityProperty($oid, 'left', $item->getLeftValue());
		}

//
//		if ($insert) {
//			// Call original local move method for items not in the database yet
//			parent::moveNode($item, $moveLeft, $moveRight, $moveLevel);
//		} else {
//			// Refresh so additional UPDATE-s are not executed on the server
//			$this->entityManager->refresh($item);
//		}
//		// Double check the values, should not happen
//		if ($item->getLeftValue() != $newLeft) {
//			$item->setLeftValue($newLeft);
//		}
//		if ($item->getRightValue() != $newRight) {
//			$item->setRightValue($newRight);
//		}
//		if ($item->getLevel() != $newLevel) {
//			$item->setLevel($newLevel);
//		}
	}
1161491
void move(AbstractTreeMap.Entry x, AbstractTreeMap.Entry y)
                    throws ObjectManagerException
    {
        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.exit(this,
                       cclass,
                       "move",
                       new Object[] { x, y });

        Entry yParent = (Entry) y.getParent();

        // Set x into the position occupied by y.
        x.setParent(yParent);

        if (yParent == null)
            setRoot(x);
        else if (yParent.getRight() == y)
            yParent.setRight(x);
        else
            yParent.setLeft(x);
        x.setLeft(y.getLeft());
        x.setRight(y.getRight());

        // Set the x to be the parent of y's children.
        if (y.getLeft() != null)
            y.getLeft().setParent(x);
        if (y.getRight() != null)
            y.getRight().setParent(x);

        x.setColor(y.getColor());
        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.exit(this,
                       cclass,
                       "move",
                       new Object[] { x });
    }
1025298
public function moveNodeInPublicWorkspace(MoveEvent $event)
    {
        $liveNode = $this->getLiveNode($event->getDocument());
        $this->nodeHelper->move($liveNode, $event->getDestId(), $event->getDestName());
    }
953339
public function setParent(AbstractParentNode $parent)
    {
        if (null !== $this->parent) {
            throw new \InvalidArgumentException('Node already got a parent!');
        }

        $this->parent = $parent;
    }
610894
public function locationMoved($locationId, $oldParentId, $newParentId)
    {
        // @todo optimize: $newLocationAliasId is already available in self::publishUrlAliasForLocation() as $newId
        $newParentLocationAliasId = $this->getRealAliasId($newParentId);
        $newLocationAlias = $this->gateway->loadAutogeneratedEntry(
            'eznode:' . $locationId,
            $newParentLocationAliasId
        );

        $oldParentLocationAliasId = $this->getRealAliasId($oldParentId);
        $oldLocationAlias = $this->gateway->loadAutogeneratedEntry(
            'eznode:' . $locationId,
            $oldParentLocationAliasId
        );

        // Historize alias for old location
        $this->gateway->historizeId($oldLocationAlias['id'], $newLocationAlias['id']);
        // Reparent subtree of old location to new location
        $this->gateway->reparent($oldLocationAlias['id'], $newLocationAlias['id']);
    }
1287310
public function resolveNextNode(NodeContract $node, NodeContract $new_node)
    {
        if ($new_node->next() && ($new_node->next() instanceof Nodes\GroupNode)) {
            $values = $new_node->next()->valueToString();

            $new_node->next()->removeAllChildren();

            foreach (explode(',', $values) as $value) {
                $vn = new Nodes\ValueNode();
                $vn->setValue($value);

                $new_node->next()->addChild($vn);
            }

            $new_node->moveNodeAsChild($new_node->next());
        } else {
            throw new Exceptions\QuerySyntaxException($node->getRoot()->getValue());
        }
    }
338031
public function resolveNextNode(NodeContract $node, NodeContract $new_node)
    {
        if ($new_node->next() && $new_node->next() instanceof ComparableNodeContract) {
            $new_node->moveNodeAsChild($new_node->next());
        } else {
            throw new Exceptions\QuerySyntaxException($node->getRoot()->getValue());
        }
    }
318594
public function reorder(TreeNodeInterface $node, TreeNodeInterface $beforeNode)
    {
        if ($beforeNode->getParentNode()->getId() !== $node->getParentNode()->getId()) {
            throw new InvalidNodeMoveException('Node and targetNode need to have the same parent.');
        }

        if ($node->getParentNode()->getSortMode() !== 'free') {
            return;
        }

        $sort = $beforeNode->getSort() + 1;

        $event = new ReorderNodeEvent($node, $sort);
        if ($this->dispatcher->dispatch(TreeEvents::BEFORE_REORDER_NODE, $event)->isPropagationStopped()) {
            return;
        }

        $updatesNodes = [];

        $currentSort = $sort + 1;
        foreach ($this->getChildren($node->getParentNode()) as $childNode) {
            if ($childNode->getSort() <= $sort) {
                $childNode->setSort($currentSort++);
                $updatesNodes[] = $childNode;
            }
        }

        $node->setSort($sort);
        $updateNodes[] = $node;

        $this->updateNodes($updateNodes);

        $event = new NodeEvent($node);
        $this->dispatcher->dispatch(TreeEvents::REORDER_NODE, $event);

        return;
    }
135718
protected void moveChildNodes(final DOMNode sourceNode, final DOMNode targetNode) {

		DOMNode child = (DOMNode) sourceNode.getFirstChild();

		while (child != null) {

			DOMNode next = (DOMNode) child.getNextSibling();

			targetNode.appendChild(child);

			child = next;

		}

	}
1174681
public function setParent($parent)
    {
        if ($parent !== null &&  !$parent instanceof BaseEntry) {
            throw new \InvalidArgumentException('An entry may only have another entry as parent');
        }

        $this->parent = $parent;
    }
43768
public function moveLast($parentId = false)
    {
        if ( $this->parentIdField && $parentId === false ) {
            $parentId = $this->owner->{$this->parentIdField};
        }
        $maxIdx = $this->getMaxIdx($parentId);
        if ( $maxIdx == $this->defaultSortVal ) {
            $this->reorder($parentId);
            $maxIdx = $this->getMaxIdx($parentId);
        }
        if ( $this->parentIdField ) {
            call_user_func("$this->ownerClassName::updateAll", [
                $this->sortField => $maxIdx + 100,
                $this->parentIdField => $parentId,
            ], [ $this->primaryKey => $this->owner->primaryKey ]);
        } else {
            call_user_func("$this->ownerClassName::updateAll",
                [ $this->sortField => $maxIdx + 100 ],
                [ $this->primaryKey => $this->owner->primaryKey ]);
        }
        $this->invalidateTagDependency();
    }
539805
public function moveNode(Node $node, Node $parent)
    {
        $node->setParent($parent)->updateId();
        $this->idList[$node->id] = $node;

        return $this;
    }
324732
public function moveAsPrevSiblingOf(NodeInterface $beforeNode)
	{
		$pos = $beforeNode->getLeftValue();
		$level = $beforeNode->getLevel();
		$this->move($pos, $level);
		
		return $this;
	}
106684
public function setParent(InnerNode $parent): AbstractNode
    {
        // check integrity
        if ($this->isDescendant($parent->id())) {
            throw new CircularException('Can not add descendant "'.$parent->id().'" as my parent.');
        }

		// clear cache
		$this->clear();

        return parent::setParent($parent);
    }