/**
  * Move the given node instance to the target workspace
  *
  * If no target node variant (having the same dimension values) exists in the target workspace, the node that
  * is published will be used as a new node variant in the target workspace.
  *
  * @param NodeInterface $node The node to publish
  * @param Workspace $targetWorkspace The workspace to publish to
  * @return void
  */
 protected function moveNodeVariantToTargetWorkspace(NodeInterface $node, Workspace $targetWorkspace)
 {
     $nodeData = $node->getNodeData();
     $movedShadowNodeData = $this->nodeDataRepository->findOneByMovedTo($nodeData);
     if ($movedShadowNodeData instanceof NodeData && $movedShadowNodeData->isRemoved()) {
         $this->nodeDataRepository->remove($movedShadowNodeData);
     }
     if ($targetWorkspace->getBaseWorkspace() === null && $node->isRemoved()) {
         $this->nodeDataRepository->remove($nodeData);
     } else {
         $nodeData->setWorkspace($targetWorkspace);
         $nodeData->setLastPublicationDateTime($this->now);
         $this->nodeService->cleanUpProperties($node);
     }
     $node->setNodeDataIsMatchingContext(null);
 }
 /**
  * Move the given node instance to the target workspace
  *
  * If no target node variant (having the same dimension values) exists in the target workspace, the node that
  * is published will be used as a new node variant in the target workspace.
  *
  * @param NodeInterface $node The node to publish
  * @param Workspace $targetWorkspace The workspace to publish to
  * @return void
  */
 protected function moveNodeVariantToTargetWorkspace(NodeInterface $node, Workspace $targetWorkspace)
 {
     $nodeData = $node->getNodeData();
     $this->handleShadowNodeData($nodeData, $targetWorkspace, $nodeData);
     // Technically this shouldn't be needed but due to doctrines behavior we need it.
     if ($nodeData->isRemoved() && $targetWorkspace->getBaseWorkspace() === null) {
         $this->nodeDataRepository->remove($nodeData);
         return;
     }
     $nodeData->setMovedTo(null);
     $nodeData->setWorkspace($targetWorkspace);
     $nodeData->setLastPublicationDateTime($this->now);
     $node->setNodeDataIsMatchingContext(null);
     $this->nodeService->cleanUpProperties($node);
 }