Neos\ContentRepository\Domain\Model\NodeInterface::copyInto PHP Метод

copyInto() публичный Метод

Copies this node to below the given node. The new node will be added behind any existing sub nodes of the given node.
public copyInto ( Neos\ContentRepository\Domain\Model\NodeInterface $referenceNode, string $nodeName ) : Neos\ContentRepository\Domain\Model\NodeInterface
$referenceNode Neos\ContentRepository\Domain\Model\NodeInterface
$nodeName string
Результат Neos\ContentRepository\Domain\Model\NodeInterface
    public function copyInto(NodeInterface $referenceNode, $nodeName);

Usage Example

 /**
  * Copy $node before, into or after $targetNode
  *
  * @param NodeInterface $node the node to be copied
  * @param NodeInterface $targetNode the target node to be copied "to", see $position
  * @param string $position where the node should be added in relation to $targetNode (allowed: before, into, after)
  * @param string $nodeName optional node name (if empty random node name will be generated)
  * @return NodeInterface The copied node
  * @throws NodeException
  */
 public function copy(NodeInterface $node, NodeInterface $targetNode, $position, $nodeName = null)
 {
     if (!in_array($position, array('before', 'into', 'after'), true)) {
         throw new NodeException('The position should be one of the following: "before", "into", "after".', 1346832303);
     }
     $nodeName = $this->nodeService->generateUniqueNodeName($this->getDesignatedParentNode($targetNode, $position)->getPath(), !empty($nodeName) ? $nodeName : null);
     switch ($position) {
         case 'before':
             $copiedNode = $node->copyBefore($targetNode, $nodeName);
             break;
         case 'after':
             $copiedNode = $node->copyAfter($targetNode, $nodeName);
             break;
         case 'into':
         default:
             $copiedNode = $node->copyInto($targetNode, $nodeName);
     }
     return $copiedNode;
 }