WorkspaceService
final class WorkspaceService (View source)
Central authority to interact with Content Repository Workspaces within Neos
Methods
No description
Load metadata for the specified workspace
Update/set title metadata for the specified workspace
Update/set description metadata for the specified workspace
Retrieve the personal workspace for the specified user, if no workspace exist an exception is thrown.
Create a new root (aka base) workspace with the specified metadata
Create a new, personal, workspace for the specified user (fails if the user already owns a workspace)
Create a new, potentially shared, workspace
Create a new, personal, workspace for the specified user if none exists yet
Assign a workspace role to the given user/user group
Remove a workspace role assignment for the given subject
Deletes a content repository workspace and also all role assignments and metadata
Get all role assignments for the specified workspace
Builds a workspace name that is unique within the specified content repository.
Details
__construct(ContentRepositoryRegistry $contentRepositoryRegistry, WorkspaceMetadataAndRoleRepository $metadataAndRoleRepository, UserService $userService, ContentRepositoryAuthorizationService $authorizationService, Context $securityContext, SoftRemovalGarbageCollector $softRemovalGarbageCollector)
No description
WorkspaceMetadata
getWorkspaceMetadata(ContentRepositoryId $contentRepositoryId, WorkspaceName $workspaceName)
Load metadata for the specified workspace
Note: If no metadata exists for the specified workspace, metadata with title based on the name and classification according to the content repository workspace is returned. Root workspaces are of classification ROOT whereas simple ones will yield UNKNOWN. {\Neos\Neos\Domain\Model\WorkspaceClassification::UNKNOWN}
void
setWorkspaceTitle(ContentRepositoryId $contentRepositoryId, WorkspaceName $workspaceName, WorkspaceTitle $newWorkspaceTitle)
Update/set title metadata for the specified workspace
void
setWorkspaceDescription(ContentRepositoryId $contentRepositoryId, WorkspaceName $workspaceName, WorkspaceDescription $newWorkspaceDescription)
Update/set description metadata for the specified workspace
Workspace
getPersonalWorkspaceForUser(ContentRepositoryId $contentRepositoryId, UserId $userId)
Retrieve the personal workspace for the specified user, if no workspace exist an exception is thrown.
void
createRootWorkspace(ContentRepositoryId $contentRepositoryId, WorkspaceName $workspaceName, WorkspaceTitle $title, WorkspaceDescription $description, WorkspaceRoleAssignments $assignments)
Create a new root (aka base) workspace with the specified metadata
To ensure that editors can publish to the live workspace and to allow everybody to view it an assignment like {\Neos\Neos\Domain\Model\WorkspaceRoleAssignments::createForLiveWorkspace} needs to be specified:
$this->workspaceService->createRootWorkspace( $contentRepositoryId, WorkspaceName::forLive(), WorkspaceTitle::fromString('Public live workspace'), WorkspaceDescription::empty(), WorkspaceRoleAssignments::createForLiveWorkspace() );
void
createPersonalWorkspace(ContentRepositoryId $contentRepositoryId, WorkspaceName $workspaceName, WorkspaceTitle $title, WorkspaceDescription $description, WorkspaceName $baseWorkspaceName, UserId $ownerId)
Create a new, personal, workspace for the specified user (fails if the user already owns a workspace)
void
createSharedWorkspace(ContentRepositoryId $contentRepositoryId, WorkspaceName $workspaceName, WorkspaceTitle $title, WorkspaceDescription $description, WorkspaceName $baseWorkspaceName, WorkspaceRoleAssignments $assignments)
Create a new, potentially shared, workspace
To ensure that the user can manage the shared workspace and to enable collaborates an assignment like {\Neos\Neos\Domain\Model\WorkspaceRoleAssignments::createForSharedWorkspace} needs to be specified:
$this->workspaceService->createWorkspace(
...,
assignments: WorkspaceRoleAssignments::createForSharedWorkspace(
$currentUser->getId()
)
);
NOTE: By default - if no role assignments are specified - only administrators can manage workspaces without role assignments.
void
createPersonalWorkspaceForUserIfMissing(ContentRepositoryId $contentRepositoryId, User $user)
Create a new, personal, workspace for the specified user if none exists yet
void
assignWorkspaceRole(ContentRepositoryId $contentRepositoryId, WorkspaceName $workspaceName, WorkspaceRoleAssignment $assignment)
Assign a workspace role to the given user/user group
Without explicit workspace roles, only administrators can change the corresponding workspace. With this method, the subject (i.e. a Neos user or group represented by a Flow role identifier) can be granted a {\Neos\Neos\Domain\Model\WorkspaceRole} for the specified workspace
void
unassignWorkspaceRole(ContentRepositoryId $contentRepositoryId, WorkspaceName $workspaceName, WorkspaceRoleSubject $subject)
Remove a workspace role assignment for the given subject
void
deleteWorkspace(ContentRepositoryId $contentRepositoryId, WorkspaceName $workspaceName)
Deletes a content repository workspace and also all role assignments and metadata
WorkspaceRoleAssignments
getWorkspaceRoleAssignments(ContentRepositoryId $contentRepositoryId, WorkspaceName $workspaceName)
Get all role assignments for the specified workspace
NOTE: This should never be used to evaluate permissions, instead {\Neos\Neos\Security\Authorization\ContentRepositoryAuthorizationService::getWorkspacePermissions()} should be used!
WorkspaceName
getUniqueWorkspaceName(ContentRepositoryId $contentRepositoryId, string $candidate)
Builds a workspace name that is unique within the specified content repository.
If $candidate already refers to a workspace name that is not used yet, it will be used (with transliteration to enforce a valid format) Otherwise a counter "-n" suffix is appended and increased until a unique name is found, or the maximum number of attempts has been reached (in which case an exception is thrown)