Neos\ContentRepository\Domain\Service\NodeServiceInterface::generateUniqueNodeName PHP Method

generateUniqueNodeName() public method

Generates a possible node name, optionally based on a suggested "ideal" name.
public generateUniqueNodeName ( string $parentPath, string $idealNodeName = null ) : string
$parentPath string
$idealNodeName string Can be any string, doesn't need to be a valid node name.
return string valid node name that is possible as child of the given $parentNode
    public function generateUniqueNodeName($parentPath, $idealNodeName = null);

Usage Example

コード例 #1
0
 /**
  * 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;
 }
All Usage Examples Of Neos\ContentRepository\Domain\Service\NodeServiceInterface::generateUniqueNodeName