Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php
public function publishOrDiscardNodesAction(array $nodes, $action, Workspace $selectedWorkspace = null)
    {
        $propertyMappingConfiguration = $this->propertyMapper->buildPropertyMappingConfiguration();
        $propertyMappingConfiguration->setTypeConverterOption(NodeConverter::class, NodeConverter::REMOVED_CONTENT_SHOWN, true);
        foreach ($nodes as $key => $node) {
            $nodes[$key] = $this->propertyMapper->convert($node, NodeInterface::class, $propertyMappingConfiguration);
        }
        switch ($action) {
            case 'publish':
                foreach ($nodes as $node) {
                    $this->publishingService->publishNode($node);
                }
                $this->addFlashMessage($this->translator->translateById('workspaces.selectedChangesHaveBeenPublished', [], null, null, 'Modules', 'Neos.Neos'));
            break;
            case 'discard':
                $this->publishingService->discardNodes($nodes);
                $this->addFlashMessage($this->translator->translateById('workspaces.selectedChangesHaveBeenDiscarded', [], null, null, 'Modules', 'Neos.Neos'));
            break;
            default:
                throw new \RuntimeException('Invalid action "' . htmlspecialchars($action) . '" given.', 1346167441);
        }

        $this->redirect('show', null, null, ['workspace' => $selectedWorkspace]);
    }
public function publishOrDiscardNodesAction(array $nodes, $action, Workspace $selectedWorkspace = null)
    {
        $propertyMappingConfiguration = $this->propertyMapper->buildPropertyMappingConfiguration();
        $propertyMappingConfiguration->setTypeConverterOption(NodeConverter::class, NodeConverter::REMOVED_CONTENT_SHOWN, true);
        foreach ($nodes as $key => $node) {
            $nodes[$key] = $this->propertyMapper->convert($node, NodeInterface::class, $propertyMappingConfiguration);
        }
        switch ($action) {
            case 'publish':
                foreach ($nodes as $node) {
                    $this->publishingService->publishNode($node);
                }
                $this->addFlashMessage($this->translator->translateById('workspaces.selectedChangesHaveBeenPublished', [], null, null, 'Modules', 'Neos.Neos'));
            break;
            case 'discard':
                $this->publishingService->discardNodes($nodes);
                $this->addFlashMessage($this->translator->translateById('workspaces.selectedChangesHaveBeenDiscarded', [], null, null, 'Modules', 'Neos.Neos'));
            break;
            default:
                throw new \RuntimeException('Invalid action "' . htmlspecialchars($action) . '" given.', 1346167441);
        }

        $this->redirect('show', null, null, ['workspace' => $selectedWorkspace]);
    }
public function publishOrDiscardNodesAction ( array $ nodes , $ action , Workspace $ selectedWorkspace = null ) { $ propertyMappingConfiguration = $ this -> propertyMapper -> buildPropertyMappingConfiguration ( ) ; $ propertyMappingConfiguration -> setTypeConverterOption ( NodeConverter :: class , NodeConverter :: REMOVED_CONTENT_SHOWN , true ) ; foreach ( $ nodes as $ key => $ node ) { $ nodes [ $ key ] = $ this -> propertyMapper -> convert ( $ node , NodeInterface :: class , $ propertyMappingConfiguration ) ; } switch ( $ action ) { case 'publish' : foreach ( $ nodes as $ node ) { $ this -> publishingService -> publishNode ( $ node ) ; } $ this -> addFlashMessage ( $ this -> translator -> translateById ( 'workspaces.selectedChangesHaveBeenPublished' , [ ] , null , null , 'Modules' , 'Neos.Neos' ) ) ; break ; case 'discard' : $ this -> publishingService -> discardNodes ( $ nodes ) ; $ this -> addFlashMessage ( $ this -> translator -> translateById ( 'workspaces.selectedChangesHaveBeenDiscarded' , [ ] , null , null , 'Modules' , 'Neos.Neos' ) ) ; break ; default : throw new \ RuntimeException ( 'Invalid action "' . htmlspecialchars ( $ action ) . '" given.' , 1346167441 ) ; } $ this -> redirect ( 'show' , null , null , [ 'workspace' => $ selectedWorkspace ] ) ; }
Publishes or discards the given nodes

@param array $nodes <\Neos\ContentRepository\Domain\Model\NodeInterface> $nodes
@param string $action
@param Workspace $selectedWorkspace
@throws \Exception
@throws \Neos\Flow\Property\Exception
@throws \Neos\Flow\Security\Exception
Publishes or discards the given nodes