本文整理汇总了PHP中TYPO3\TYPO3CR\Domain\Model\NodeInterface::copyInto方法的典型用法代码示例。如果您正苦于以下问题:PHP NodeInterface::copyInto方法的具体用法?PHP NodeInterface::copyInto怎么用?PHP NodeInterface::copyInto使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\TYPO3CR\Domain\Model\NodeInterface
的用法示例。
在下文中一共展示了NodeInterface::copyInto方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: copy
/**
* 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;
}
示例2: copyIntoAction
/**
* Copy $node into $targetNode
*
* @param \TYPO3\TYPO3CR\Domain\Model\NodeInterface $node
* @param \TYPO3\TYPO3CR\Domain\Model\NodeInterface $targetNode
* @param string $nodeName optional node name (if empty random node name will be generated)
* @return void
* @ExtDirect
*/
public function copyIntoAction(\TYPO3\TYPO3CR\Domain\Model\NodeInterface $node, \TYPO3\TYPO3CR\Domain\Model\NodeInterface $targetNode, $nodeName = '')
{
$nodeName = $nodeName === '' ? uniqid('node') : $nodeName;
$node->copyInto($targetNode, $nodeName);
$this->view->assign('value', array('success' => TRUE));
}