Neos\Neos\Domain\Service\UserService::currentUserCanTransferOwnershipOfWorkspace PHP Method

currentUserCanTransferOwnershipOfWorkspace() public method

In future versions, this logic may be implemented in Neos in a more generic way (for example, by means of an ACL object), but for now, this method exists in order to at least centralize and encapsulate the required logic.
public currentUserCanTransferOwnershipOfWorkspace ( Workspace $workspace ) : boolean
$workspace Neos\ContentRepository\Domain\Model\Workspace The workspace
return boolean
    public function currentUserCanTransferOwnershipOfWorkspace(Workspace $workspace)
    {
        if ($workspace->isPersonalWorkspace()) {
            return false;
        }
        // The privilege to manage shared workspaces is needed, because regular editors should not change ownerships
        // of their internal workspaces, even if it was technically possible, because they wouldn't be able to change
        // ownership back to themselves.
        return $this->privilegeManager->isPrivilegeTargetGranted('Neos.Neos:Backend.Module.Management.Workspaces.ManageInternalWorkspaces');
    }

Usage Example

Example #1
0
 /**
  * Edit a workspace
  *
  * @param Workspace $workspace
  * @return void
  */
 public function editAction(Workspace $workspace)
 {
     $this->view->assign('workspace', $workspace);
     $this->view->assign('baseWorkspaceOptions', $this->prepareBaseWorkspaceOptions($workspace));
     $this->view->assign('disableBaseWorkspaceSelector', $this->publishingService->getUnpublishedNodesCount($workspace) > 0);
     $this->view->assign('showOwnerSelector', $this->userService->currentUserCanTransferOwnershipOfWorkspace($workspace));
     $this->view->assign('ownerOptions', $this->prepareOwnerOptions());
 }