Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I duplicate/propogate children structure of a node #45

Open
akudryav opened this issue Mar 30, 2022 · 1 comment
Open

How can I duplicate/propogate children structure of a node #45

akudryav opened this issue Mar 30, 2022 · 1 comment
Labels

Comments

@akudryav
Copy link

Is it possible to duplicate child of a node with all its subchildren structure? Give example please.

@BlueM BlueM added the question label Oct 3, 2024
@BlueM
Copy link
Owner

BlueM commented Oct 3, 2024

Depends on what you are trying to do. If you want to alter the tree, then there is no built-in support for this, as the library is aimed at read-only access to tree data.

However, nothing keeps you from doing something like this:

$nodeToBeCloned = $tree->getNodeById($idOfNodeToBeCloned);
$clone = clone $nodeToBeCloned;
$nodeToBeCloned->getParent()->addChild($clone);

(And by the way: sorry for the late answer. Chances are that you don’t need it anymore …)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants