本文整理汇总了PHP中TYPO3\TYPO3CR\Domain\Repository\WorkspaceRepository::findOneByTitle方法的典型用法代码示例。如果您正苦于以下问题:PHP WorkspaceRepository::findOneByTitle方法的具体用法?PHP WorkspaceRepository::findOneByTitle怎么用?PHP WorkspaceRepository::findOneByTitle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\TYPO3CR\Domain\Repository\WorkspaceRepository
的用法示例。
在下文中一共展示了WorkspaceRepository::findOneByTitle方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createAction
/**
* Create a workspace
*
* @Flow\Validate(argumentName="title", type="\TYPO3\Flow\Validation\Validator\NotEmptyValidator")
* @param string $title Human friendly title of the workspace, for example "Christmas Campaign"
* @param Workspace $baseWorkspace Workspace the new workspace should be based on
* @param string $visibility Visibility of the new workspace, must be either "internal" or "shared"
* @param string $description A description explaining the purpose of the new workspace
* @return void
*/
public function createAction($title, Workspace $baseWorkspace, $visibility, $description = '')
{
$workspace = $this->workspaceRepository->findOneByTitle($title);
if ($workspace instanceof Workspace) {
$this->addFlashMessage($this->translator->translateById('workspaces.workspaceWithThisTitleAlreadyExists', [], null, null, 'Modules', 'TYPO3.Neos'), '', Message::SEVERITY_WARNING);
$this->redirect('new');
}
$workspaceName = Utility::renderValidNodeName($title) . '-' . substr(base_convert(microtime(false), 10, 36), -5, 5);
while ($this->workspaceRepository->findOneByName($workspaceName) instanceof Workspace) {
$workspaceName = Utility::renderValidNodeName($title) . '-' . substr(base_convert(microtime(false), 10, 36), -5, 5);
}
if ($visibility === 'private') {
$owner = $this->userService->getCurrentUser();
} else {
$owner = null;
}
$workspace = new Workspace($workspaceName, $baseWorkspace, $owner);
$workspace->setTitle($title);
$workspace->setDescription($description);
$this->workspaceRepository->add($workspace);
$this->redirect('index');
}