Neos.Neos/Classes/Command/WorkspaceCommandController.php
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', [$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.', [$workspaceName]);
            $this->quit(1);
        }

        $this->outputLine('The workspace %s contains %u unpublished nodes.', [$workspaceName, count($nodes)]);

        foreach ($nodes as $node) {
            /** @var 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', [$workspaceName]);
        }
    }
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', [$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.', [$workspaceName]);
            $this->quit(1);
        }

        $this->outputLine('The workspace %s contains %u unpublished nodes.', [$workspaceName, count($nodes)]);

        foreach ($nodes as $node) {
            /** @var 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', [$workspaceName]);
        }
    }
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' , [ $ 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.' , [ $ workspaceName ] ) ; $ this -> quit ( 1 ) ; } $ this -> outputLine ( 'The workspace %s contains %u unpublished nodes.' , [ $ workspaceName , count ( $ nodes ) ] ) ; foreach ( $ nodes as $ node ) { /** @var 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' , [ $ workspaceName ] ) ; } }
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
Discard changes in workspace