当前位置: 首页>>代码示例>>PHP>>正文


PHP WorkspaceRepository::findByBaseWorkspace方法代码示例

本文整理汇总了PHP中TYPO3\TYPO3CR\Domain\Repository\WorkspaceRepository::findByBaseWorkspace方法的典型用法代码示例。如果您正苦于以下问题:PHP WorkspaceRepository::findByBaseWorkspace方法的具体用法?PHP WorkspaceRepository::findByBaseWorkspace怎么用?PHP WorkspaceRepository::findByBaseWorkspace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TYPO3\TYPO3CR\Domain\Repository\WorkspaceRepository的用法示例。


在下文中一共展示了WorkspaceRepository::findByBaseWorkspace方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: deleteAction

 /**
  * Delete a workspace
  *
  * @param Workspace $workspace A workspace to delete
  * @return void
  */
 public function deleteAction(Workspace $workspace)
 {
     if (substr($workspace->getName(), 0, 5) === 'user-') {
         $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', 'TYPO3.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', 'TYPO3.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', 'TYPO3.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', 'TYPO3.Neos'));
     $this->redirect('index');
 }
开发者ID:BlueM,项目名称:neos-development-collection,代码行数:39,代码来源:WorkspacesController.php

示例2: deleteCommand

 /**
  * Deletes a workspace
  *
  * This command deletes a workspace. If you only want to empty a workspace and not delete the
  * workspace itself, use <i>workspace:discard</i> instead.
  *
  * @param string $workspace Name of the workspace, for example "christmas-campaign"
  * @param boolean $force Delete the workspace and all of its contents
  * @return void
  * @see typo3.neos:workspace:discard
  */
 public function deleteCommand($workspace, $force = false)
 {
     $workspaceName = $workspace;
     $workspace = $this->workspaceRepository->findOneByName($workspaceName);
     if (!$workspace instanceof Workspace) {
         $this->outputLine('Workspace "%s" does not exist', [$workspaceName]);
         $this->quit(1);
     }
     if ($workspace->isPersonalWorkspace()) {
         $this->outputLine('Did not delete workspace "%s" because it is a personal workspace. Personal workspaces cannot be deleted manually.', [$workspaceName]);
         $this->quit(2);
     }
     $dependentWorkspaces = $this->workspaceRepository->findByBaseWorkspace($workspace);
     if (count($dependentWorkspaces) > 0) {
         $this->outputLine('Workspace "%s" cannot be deleted because the following workspaces are based on it:', [$workspaceName]);
         $this->outputLine();
         $tableRows = [];
         $headerRow = ['Name', 'Title', 'Description'];
         /** @var Workspace $workspace */
         foreach ($dependentWorkspaces as $workspace) {
             $tableRows[] = [$workspace->getName(), $workspace->getTitle(), $workspace->getDescription()];
         }
         $this->output->outputTable($tableRows, $headerRow);
         $this->quit(3);
     }
     try {
         $nodesCount = $this->publishingService->getUnpublishedNodesCount($workspace);
     } catch (\Exception $exception) {
         $this->outputLine('An error occurred while fetching unpublished nodes from workspace %s, nothing was deleted.', [$workspaceName]);
         $this->quit(4);
     }
     if ($nodesCount > 0) {
         if ($force === false) {
             $this->outputLine('Did not delete workspace "%s" because it contains %s unpublished node(s). Use --force to delete it nevertheless.', [$workspaceName, $nodesCount]);
             $this->quit(5);
         }
         $this->discardCommand($workspaceName);
     }
     $this->workspaceRepository->remove($workspace);
     $this->outputLine('Deleted workspace "%s"', [$workspaceName]);
 }
开发者ID:cognifloyd,项目名称:neos-development-collection,代码行数:52,代码来源:WorkspaceCommandController.php


注:本文中的TYPO3\TYPO3CR\Domain\Repository\WorkspaceRepository::findByBaseWorkspace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。