/**
  * Publishes the given node to the specified targetWorkspace
  *
  * @param \TYPO3\TYPO3CR\Domain\Model\NodeInterface $node
  * @param string $targetWorkspaceName
  * @return void
  * @ExtDirect
  */
 public function publishNodeAction(\TYPO3\TYPO3CR\Domain\Model\NodeInterface $node, $targetWorkspaceName)
 {
     /**
      * TODO: The publishing pushes the same node twice, which causes the node to be published
      * already when it's processed the second time. This obviously leads to a problem for the
      * Workspace object which will (in the second time) try to publish a node in the live workspace
      * to the baseWorkspace of the live workspace (which does not exist).
      */
     if ($targetWorkspaceName === $node->getWorkspace()->getName()) {
         $this->view->assign('value', array('success' => TRUE));
         return;
     }
     $this->workspacesService->publishNode($node, $targetWorkspaceName);
     $this->view->assign('value', array('success' => TRUE));
 }
 /**
  * @param array<\TYPO3\TYPO3CR\Domain\Model\NodeInterface> $nodes
  * @param string $action
  * @return void
  */
 public function publishOrDiscardNodesAction(array $nodes, $action)
 {
     $propertyMappingConfiguration = $this->propertyMappingConfigurationBuilder->build();
     $propertyMappingConfiguration->setTypeConverterOption('TYPO3\\TYPO3\\Routing\\NodeObjectConverter', \TYPO3\TYPO3\Routing\NodeObjectConverter::REMOVED_CONTENT_SHOWN, TRUE);
     foreach ($nodes as $key => $node) {
         $nodes[$key] = $this->propertyMapper->convert($node, 'TYPO3\\TYPO3CR\\Domain\\Model\\NodeInterface', $propertyMappingConfiguration);
     }
     switch ($action) {
         case 'publish':
             foreach ($nodes as $node) {
                 $this->workspacesService->publishNode($node);
             }
             $message = 'Selected changes have been published';
             break;
         case 'discard':
             foreach ($nodes as $node) {
                 $this->nodeRepository->remove($node);
             }
             $message = 'Selected changes have been discarded';
             break;
         default:
             throw new \RuntimeException('Invalid action "' . $action . '" given.', 1346167441);
     }
     $this->flashMessageContainer->addMessage(new \TYPO3\FLOW3\Error\Message($message));
     $this->redirect('index');
 }