/** * Replace the node data of a node instance with a given target node data * * 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. * * @param NodeInterface $node The node instance with node data to be published * @param NodeData $targetNodeData The existing node data in the target workspace * @return void */ protected function replaceNodeData(NodeInterface $node, NodeData $targetNodeData) { $sourceNodeData = $node->getNodeData(); $nodeWasMoved = false; $movedShadowNodeData = $this->nodeDataRepository->findOneByMovedTo($sourceNodeData); if ($movedShadowNodeData instanceof NodeData) { $nodeWasMoved = true; if ($movedShadowNodeData->isRemoved()) { $this->nodeDataRepository->remove($movedShadowNodeData); } } if ($node->isRemoved() === true) { $this->nodeDataRepository->remove($targetNodeData); } else { $targetNodeData->similarize($node->getNodeData()); if ($nodeWasMoved) { $targetNodeData->setPath($node->getPath(), false); } $targetNodeData->setLastPublicationDateTime($this->now); $node->setNodeData($targetNodeData); $this->nodeService->cleanUpProperties($node); } $this->nodeDataRepository->remove($sourceNodeData); }
/** * Moves the given node to the destination path by modifying the underlaying NodeData object. * * @param NodeInterface $node * @param string $destinationPath * @return void */ protected function moveNodeToDestinationPath(NodeInterface $node, $destinationPath) { $nodeData = $node->getNodeData(); $possibleShadowedNodeData = $nodeData->move($destinationPath, $this->context->getWorkspace()); $node->setNodeData($possibleShadowedNodeData); }
/** * Replace the node data of a node instance with a given target node data * * 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. * * @param NodeInterface $node The node instance with node data to be published * @param NodeData $targetNodeData 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); }
/** * Replace the node data of a node instance with a given target node data * * 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. * * @param NodeInterface $node The node instance with node data to be published * @param NodeData $targetNodeData The existing node data in the target workspace * @return void */ protected function replaceNodeData(NodeInterface $node, NodeData $targetNodeData) { $sourceNodeData = $node->getNodeData(); if ($node->isRemoved() === TRUE) { $this->nodeDataRepository->remove($targetNodeData); } else { $targetNodeData->similarize($node->getNodeData()); $targetNodeData->setPath($node->getPath(), FALSE); $node->setNodeData($targetNodeData); } $this->nodeDataRepository->remove($sourceNodeData); }