Neos\ContentRepository\Domain\Model\Workspace::getOwner PHP Method

getOwner() public method

Returns the workspace owner.
public getOwner ( ) : Neos\ContentRepository\Domain\Model\UserInterface
return Neos\ContentRepository\Domain\Model\UserInterface
    public function getOwner()
    {
        if ($this->owner === null) {
            return null;
        }
        return $this->persistenceManager->getObjectByIdentifier($this->owner, $this->reflectionService->getDefaultImplementationClassNameForInterface(UserInterface::class));
    }

Usage Example

コード例 #1
0
 /**
  * Checks if the current user may manage the given workspace according to one the roles of the user's accounts
  *
  * 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.
  *
  * @param Workspace $workspace The workspace
  * @return boolean
  */
 public function currentUserCanManageWorkspace(Workspace $workspace)
 {
     if ($workspace->isPersonalWorkspace()) {
         return false;
     }
     if ($workspace->isInternalWorkspace()) {
         return $this->privilegeManager->isPrivilegeTargetGranted('Neos.Neos:Backend.Module.Management.Workspaces.ManageInternalWorkspaces');
     }
     if ($workspace->isPrivateWorkspace() && $workspace->getOwner() === $this->getCurrentUser()) {
         return $this->privilegeManager->isPrivilegeTargetGranted('Neos.Neos:Backend.Module.Management.Workspaces.ManageOwnWorkspaces');
     }
     if ($workspace->isPrivateWorkspace() && $workspace->getOwner() !== $this->getCurrentUser()) {
         return $this->privilegeManager->isPrivilegeTargetGranted('Neos.Neos:Backend.Module.Management.Workspaces.ManageAllPrivateWorkspaces');
     }
     return false;
 }