/** * Discard a a single node * * @param NodeInterface $node * @param Workspace $selectedWorkspace * @throws \TYPO3\TYPO3CR\Exception\WorkspaceException */ public function discardNodeAction(NodeInterface $node, Workspace $selectedWorkspace) { // Hint: we cannot use $node->remove() here, as this removes the node recursively (but we just want to *discard changes*) $this->publishingService->discardNode($node); $this->addFlashMessage($this->translator->translateById('workspaces.selectedChangeHasBeenDiscarded', [], null, null, 'Modules', 'TYPO3.Neos')); $this->redirect('show', null, null, ['workspace' => $selectedWorkspace]); }
/** * Discard a a single node * * @param NodeInterface $node * @return void */ public function discardNodeAction(NodeInterface $node) { // Hint: we cannot use $node->remove() here, as this removes the node recursively (but we just want to *discard changes*) $this->publishingService->discardNode($node); $this->addFlashMessage('Node has been discarded', 'Node discarded', NULL, array(), 1412420292); $this->redirect('index'); }
/** * Discard changes in workspace * * This command discards all modified, created or deleted nodes in the specified workspace. * * @param string $workspace Name of the workspace, for example "user-john" * @param boolean $verbose If enabled, information about individual nodes will be displayed * @param boolean $dryRun If set, only displays which nodes would be discarded, no real changes are committed * @return void */ public function discardCommand($workspace, $verbose = FALSE, $dryRun = FALSE) { $workspaceName = $workspace; $workspace = $this->workspaceRepository->findOneByName($workspaceName); if (!$workspace instanceof Workspace) { $this->outputLine('Workspace "%s" does not exist', array($workspaceName)); $this->quit(1); } try { $nodes = $this->publishingService->getUnpublishedNodes($workspace); } catch (\Exception $exception) { $this->outputLine('An error occurred while fetching unpublished nodes from workspace %s, discard aborted.', array($workspaceName)); $this->quit(1); } $this->outputLine('The workspace %s contains %u unpublished nodes.', array($workspaceName, count($nodes))); foreach ($nodes as $node) { /** @var \TYPO3\TYPO3CR\Domain\Model\NodeInterface $node */ if ($node->getPath() !== '/') { if ($verbose) { $this->outputLine(' ' . $node->getPath()); } if (!$dryRun) { $this->publishingService->discardNode($node); } } } if (!$dryRun) { $this->outputLine('Discarded all nodes in workspace %s', array($workspaceName)); } }
/** * Discard nodes * * @param array $nodeContextPaths * @return void */ public function discardAction(array $nodeContextPaths) { try { foreach ($nodeContextPaths as $contextPath) { $node = $this->nodeService->getNodeFromContextPath($contextPath); $this->publishingService->discardNode($node); $reloadDocument = new ReloadDocument(); $reloadDocument->setDocument($this->nodeService->getClosestDocument($node)); $this->feedbackCollection->add($reloadDocument); } $success = new Success(); $success->setMessage(sprintf('Discarded %d node(s).', count($nodeContextPaths))); $this->updateWorkspaceInfo($nodeContextPaths[0]); $this->feedbackCollection->add($success); $this->persistenceManager->persistAll(); } catch (\Exception $e) { $error = new Error(); $error->setMessage($e->getMessage()); $this->feedbackCollection->add($error); } $this->view->assign('value', $this->feedbackCollection); }
/** * Discards the given node * * @param NodeInterface $node * @return void */ public function discardNodeAction(NodeInterface $node) { $this->publishingService->discardNode($node); $this->throwStatus(204, 'Node changes have been discarded', ''); }