Neos\ContentRepository\Domain\Model\Workspace::replaceNodeData PHP Method

replaceNodeData() protected method

The node data of the node that is published will be removed and the existing node data inside the target workspace is updated to the changes and will be injected into the node instance. If the node was marked as removed, both node data are removed.
protected replaceNodeData ( Neos\ContentRepository\Domain\Model\NodeInterface $node, NodeData $targetNodeData ) : void
$node Neos\ContentRepository\Domain\Model\NodeInterface The node instance with node data to be published
$targetNodeData NodeData The existing node data in the target workspace
return void
    protected function replaceNodeData(NodeInterface $node, NodeData $targetNodeData)
    {
        $sourceNodeData = $node->getNodeData();
        $nodeWasMoved = $this->handleShadowNodeData($sourceNodeData, $targetNodeData->getWorkspace(), $targetNodeData);
        // Technically this shouldn't be needed but due to doctrines behavior we need it.
        if ($sourceNodeData->isRemoved() && $targetNodeData->getWorkspace()->getBaseWorkspace() === null) {
            $this->nodeDataRepository->remove($targetNodeData);
            $this->nodeDataRepository->remove($sourceNodeData);
            return;
        }
        $targetNodeData->similarize($sourceNodeData);
        $targetNodeData->setLastPublicationDateTime($this->now);
        if ($nodeWasMoved) {
            // TODO: This seems wrong and introduces a publish order between nodes. We should always set the path.
            $targetNodeData->setPath($node->getPath(), false);
        }
        $node->setNodeData($targetNodeData);
        $this->nodeService->cleanUpProperties($node);
        $targetNodeData->setRemoved($sourceNodeData->isRemoved());
        $this->nodeDataRepository->remove($sourceNodeData);
    }