Neos\ContentRepository\Domain\Model\Node::moveNodeData PHP Method

moveNodeData() protected method

Moves a NodeData object that is either a variant or child node to the given destination path.
protected moveNodeData ( NodeData $nodeData, string $originalPath, string $destinationPath, boolean $recursiveCall ) : array | null
$nodeData NodeData
$originalPath string
$destinationPath string
$recursiveCall boolean
return array | null
    protected function moveNodeData($nodeData, $originalPath, $destinationPath, $recursiveCall)
    {
        $recursiveCall = $recursiveCall || $this->nodeData !== $nodeData;
        $nodeVariant = null;
        // $nodeData at this point could contain *our own NodeData reference* ($this->nodeData), as we find all NodeData objects
        // (across all dimensions) with the same path.
        //
        // We need to ensure that our own Node object's nodeData reference ($this->nodeData) is also updated correctly if a new NodeData object
        // is returned; as we rely on the fact that $this->getPath() will return the new node path in all circumstances.
        //
        // However, $this->createNodeForVariant() only returns $this if the Context object is the same as $this->context; which is not
        // the case if $this->context contains dimension fallbacks such as "Language: EN, DE".
        //
        // The "if" statement below is actually a workaround to ensure that if the NodeData object is our own one, we update *ourselves* correctly,
        // and thus return the correct (new) Node Path when calling $this->getPath() afterwards.
        // FIXME: This is dangerous and probably the NodeFactory should take care of globally tracking usage of NodeData objects and replacing them in Node objects
        if ($this->nodeData === $nodeData) {
            $nodeVariant = $this;
        }
        if ($nodeVariant === null) {
            $nodeVariant = $this->createNodeForVariant($nodeData);
        }
        $moveVariantResult = $nodeVariant === null ? null : $this->moveVariantOrChild($originalPath, $destinationPath, $nodeVariant);
        if ($moveVariantResult !== null) {
            array_push($moveVariantResult, $recursiveCall);
        }
        return $moveVariantResult;
    }
Node