Neos\ContentRepository\Domain\Service\NodeServiceInterface::nodePathAvailableForNode PHP Méthode

nodePathAvailableForNode() public méthode

Checks if the given node path can be used for the given node.
public nodePathAvailableForNode ( string $nodePath, Neos\ContentRepository\Domain\Model\NodeInterface $node ) : boolean
$nodePath string
$node Neos\ContentRepository\Domain\Model\NodeInterface
Résultat boolean
    public function nodePathAvailableForNode($nodePath, NodeInterface $node);

Usage Example

 /**
  * Move $node before, into or after $targetNode
  *
  * @param NodeInterface $node
  * @param NodeInterface $targetNode
  * @param string $position where the node should be added (allowed: before, into, after)
  * @return NodeInterface The same node given as first argument
  * @throws NodeException
  */
 public function move(NodeInterface $node, NodeInterface $targetNode, $position)
 {
     if (!in_array($position, array('before', 'into', 'after'), true)) {
         throw new NodeException('The position should be one of the following: "before", "into", "after".', 1296132542);
     }
     $designatedParentNode = $this->getDesignatedParentNode($targetNode, $position);
     // If we stay inside the same parent we basically just reorder, no rename needed or wanted.
     if ($designatedParentNode !== $node->getParent()) {
         $designatedNodePath = NodePaths::addNodePathSegment($designatedParentNode->getPath(), $node->getName());
         if ($this->nodeService->nodePathAvailableForNode($designatedNodePath, $node) === false) {
             $nodeName = $this->nodeService->generateUniqueNodeName($designatedParentNode->getPath(), $node->getName());
             if ($nodeName !== $node->getName()) {
                 // FIXME: This can be removed if $node->move* supports additionally changing the name of the node.
                 $node->setName($nodeName);
             }
         }
     }
     switch ($position) {
         case 'before':
             $node->moveBefore($targetNode);
             break;
         case 'into':
             $node->moveInto($targetNode);
             break;
         case 'after':
             $node->moveAfter($targetNode);
     }
     return $node;
 }