Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php
public function deleteAction(Workspace $workspace)
    {
        if ($workspace->isPersonalWorkspace()) {
            $this->redirect('index');
        }

        $dependentWorkspaces = $this->workspaceRepository->findByBaseWorkspace($workspace);
        if (count($dependentWorkspaces) > 0) {
            $dependentWorkspaceTitles = [];
            /** @var Workspace $dependentWorkspace */
            foreach ($dependentWorkspaces as $dependentWorkspace) {
                $dependentWorkspaceTitles[] = $dependentWorkspace->getTitle();
            }

            $message = $this->translator->translateById('workspaces.workspaceCannotBeDeletedBecauseOfDependencies', [$workspace->getTitle(), implode(', ', $dependentWorkspaceTitles)], null, null, 'Modules', 'Neos.Neos');
            $this->addFlashMessage($message, '', Message::SEVERITY_WARNING);
            $this->redirect('index');
        }

        $nodesCount = 0;
        try {
            $nodesCount = $this->publishingService->getUnpublishedNodesCount($workspace);
        } catch (\Exception $exception) {
            $message = $this->translator->translateById('workspaces.notDeletedErrorWhileFetchingUnpublishedNodes', [$workspace->getTitle()], null, null, 'Modules', 'Neos.Neos');
            $this->addFlashMessage($message, '', Message::SEVERITY_WARNING);
            $this->redirect('index');
        }
        if ($nodesCount > 0) {
            $message = $this->translator->translateById('workspaces.workspaceCannotBeDeletedBecauseOfUnpublishedNodes', [$workspace->getTitle(), $nodesCount], $nodesCount, null, 'Modules', 'Neos.Neos');
            $this->addFlashMessage($message, '', Message::SEVERITY_WARNING);
            $this->redirect('index');
        }

        $this->workspaceRepository->remove($workspace);
        $this->addFlashMessage($message = $this->translator->translateById('workspaces.workspaceHasBeenRemoved', [$workspace->getTitle()], null, null, 'Modules', 'Neos.Neos'));
        $this->redirect('index');
    }
public function deleteAction(Workspace $workspace)
    {
        if ($workspace->isPersonalWorkspace()) {
            $this->redirect('index');
        }

        $dependentWorkspaces = $this->workspaceRepository->findByBaseWorkspace($workspace);
        if (count($dependentWorkspaces) > 0) {
            $dependentWorkspaceTitles = [];
            /** @var Workspace $dependentWorkspace */
            foreach ($dependentWorkspaces as $dependentWorkspace) {
                $dependentWorkspaceTitles[] = $dependentWorkspace->getTitle();
            }

            $message = $this->translator->translateById('workspaces.workspaceCannotBeDeletedBecauseOfDependencies', [$workspace->getTitle(), implode(', ', $dependentWorkspaceTitles)], null, null, 'Modules', 'Neos.Neos');
            $this->addFlashMessage($message, '', Message::SEVERITY_WARNING);
            $this->redirect('index');
        }

        $nodesCount = 0;
        try {
            $nodesCount = $this->publishingService->getUnpublishedNodesCount($workspace);
        } catch (\Exception $exception) {
            $message = $this->translator->translateById('workspaces.notDeletedErrorWhileFetchingUnpublishedNodes', [$workspace->getTitle()], null, null, 'Modules', 'Neos.Neos');
            $this->addFlashMessage($message, '', Message::SEVERITY_WARNING);
            $this->redirect('index');
        }
        if ($nodesCount > 0) {
            $message = $this->translator->translateById('workspaces.workspaceCannotBeDeletedBecauseOfUnpublishedNodes', [$workspace->getTitle(), $nodesCount], $nodesCount, null, 'Modules', 'Neos.Neos');
            $this->addFlashMessage($message, '', Message::SEVERITY_WARNING);
            $this->redirect('index');
        }

        $this->workspaceRepository->remove($workspace);
        $this->addFlashMessage($message = $this->translator->translateById('workspaces.workspaceHasBeenRemoved', [$workspace->getTitle()], null, null, 'Modules', 'Neos.Neos'));
        $this->redirect('index');
    }
public function deleteAction ( Workspace $ workspace ) { if ( $ workspace -> isPersonalWorkspace ( ) ) { $ this -> redirect ( 'index' ) ; } $ dependentWorkspaces = $ this -> workspaceRepository -> findByBaseWorkspace ( $ workspace ) ; if ( count ( $ dependentWorkspaces ) > 0 ) { $ dependentWorkspaceTitles = [ ] ; /** @var Workspace $dependentWorkspace */ foreach ( $ dependentWorkspaces as $ dependentWorkspace ) { $ dependentWorkspaceTitles [ ] = $ dependentWorkspace -> getTitle ( ) ; } $ message = $ this -> translator -> translateById ( 'workspaces.workspaceCannotBeDeletedBecauseOfDependencies' , [ $ workspace -> getTitle ( ) , implode ( ', ' , $ dependentWorkspaceTitles ) ] , null , null , 'Modules' , 'Neos.Neos' ) ; $ this -> addFlashMessage ( $ message , '' , Message :: SEVERITY_WARNING ) ; $ this -> redirect ( 'index' ) ; } $ nodesCount = 0 ; try { $ nodesCount = $ this -> publishingService -> getUnpublishedNodesCount ( $ workspace ) ; } catch ( \ Exception $ exception ) { $ message = $ this -> translator -> translateById ( 'workspaces.notDeletedErrorWhileFetchingUnpublishedNodes' , [ $ workspace -> getTitle ( ) ] , null , null , 'Modules' , 'Neos.Neos' ) ; $ this -> addFlashMessage ( $ message , '' , Message :: SEVERITY_WARNING ) ; $ this -> redirect ( 'index' ) ; } if ( $ nodesCount > 0 ) { $ message = $ this -> translator -> translateById ( 'workspaces.workspaceCannotBeDeletedBecauseOfUnpublishedNodes' , [ $ workspace -> getTitle ( ) , $ nodesCount ] , $ nodesCount , null , 'Modules' , 'Neos.Neos' ) ; $ this -> addFlashMessage ( $ message , '' , Message :: SEVERITY_WARNING ) ; $ this -> redirect ( 'index' ) ; } $ this -> workspaceRepository -> remove ( $ workspace ) ; $ this -> addFlashMessage ( $ message = $ this -> translator -> translateById ( 'workspaces.workspaceHasBeenRemoved' , [ $ workspace -> getTitle ( ) ] , null , null , 'Modules' , 'Neos.Neos' ) ) ; $ this -> redirect ( 'index' ) ; }
Delete a workspace

@param Workspace $workspace A workspace to delete
@return void
Delete a workspace