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);
}