class Workspace (View source)

A Workspace

Constants

PERSONAL_WORKSPACE_PREFIX

This prefix determines if a given workspace (name) is a user workspace.

Properties

protected string $name
protected string $title

A user-defined, human-friendly title for this workspace

protected string $description

An optional user-defined description

protected string $owner

This property contains a UUID of the User object which is the owner of this workspace.

protected Workspace $baseWorkspace

Workspace (if any) this workspace is based on.

protected NodeData $rootNodeData

Root node data of this workspace

protected NodeDataRepository $nodeDataRepository
protected PublishingServiceInterface $publishingService
protected NodeServiceInterface $nodeService
protected Now $now
protected ReflectionService $reflectionService
protected PersistenceManagerInterface $persistenceManager

Methods

__construct(string $name, Workspace $baseWorkspace = null, UserInterface $owner = null)

Constructs a new workspace

void
initializeObject(int $initializationCause)

Initializes this workspace.

string
getName()

Returns the name of this workspace

string
getTitle()

Returns the workspace title

void
setTitle(string $title)

Sets workspace title

string|null
getDescription()

Returns the workspace description

void
setDescription(string $description)

Sets the workspace description

UserInterface|null
getOwner()

Returns the workspace owner.

void
setOwner(UserInterface|string|null $user)

Returns the workspace owner.

bool
isPersonalWorkspace()

Checks if this workspace is a user's personal workspace

bool
isPrivateWorkspace()

Checks if this workspace is shared only across users with access to internal workspaces, for example "reviewers"

bool
isInternalWorkspace()

Checks if this workspace is shared across all editors

bool
isPublicWorkspace()

Checks if this workspace is public to everyone, even without authentication

void
setBaseWorkspace(Workspace $baseWorkspace)

Sets the base workspace

Workspace|null
getBaseWorkspace()

Returns the base workspace, if any

array
getBaseWorkspaces()

Returns all base workspaces, if any

getRootNodeData()

Returns the root node data of this workspace

void
publish(Workspace $targetWorkspace)

Publishes the content of this workspace to another workspace.

void
publishNodes(array $nodes, Workspace $targetWorkspace)

Publishes the given nodes to the target workspace.

void
publishNode(NodeInterface $nodeToPublish, Workspace $targetWorkspace)

Publishes the given node to the target workspace.

bool
publishNodeCanBeSkipped(NodeInterface $node, Workspace $targetWorkspace)

Checks if the given node can / needs to be published to the given target workspace or if that operation can be skipped.

void
replaceNodeData(NodeInterface $sourceNode, NodeData $targetNodeData)

Replace the node data of a node instance with a given target node data

void
moveNodeVariantsInOtherWorkspaces(string $nodeIdentifier, string $targetPath, Workspace $sourceWorkspace, Workspace $targetWorkspace)

Moves variants of a given node which exists in other workspaces than source and target workspace.

moveTargetNodeDataToNewPosition(NodeData $targetNodeData, string $destinationPath)

Moves an existing node in a target workspace to the place it should be in after publish, in order to move all children to the new position as well.

void
moveNodeVariantToTargetWorkspace(NodeInterface $nodeToPublish, Workspace $targetWorkspace)

Move the given node instance to the target workspace

void
adjustShadowNodeDataForNodePublishing(NodeData $sourceNodeData, Workspace $targetWorkspace, NodeData $targetNodeData)

Adjusts related shadow nodes for a "publish node" operation.

int
getNodeCount()

Returns the number of nodes in this workspace.

void
verifyPublishingTargetWorkspace(Workspace $targetWorkspace)

Checks if the specified workspace is a base workspace of this workspace and if not, throws an exception

NodeData|null
findCorrespondingNodeDataInTargetWorkspace(NodeInterface $node, Workspace $targetWorkspace)

Returns the NodeData instance with the given identifier from the target workspace.

void
emitBaseWorkspaceChanged(Workspace $workspace, Workspace $oldBaseWorkspace = null, Workspace $newBaseWorkspace = null)

Emits a signal after the base workspace has been changed

void
emitBeforeNodePublishing(NodeInterface $node, Workspace $targetWorkspace)

Emits a signal just before a node is being published

void
emitAfterNodePublishing(NodeInterface $node, Workspace $targetWorkspace)

Emits a signal when a node has been published.

Details

__construct(string $name, Workspace $baseWorkspace = null, UserInterface $owner = null)

Constructs a new workspace

Parameters

string $name

Name of this workspace

Workspace $baseWorkspace

A workspace this workspace is based on (if any)

UserInterface $owner

The user that created the workspace (if any, "system" workspaces have none)

void initializeObject(int $initializationCause)

Initializes this workspace.

If this workspace is brand new, a root node is created automatically.

Parameters

int $initializationCause

Return Value

void

string getName()

Returns the name of this workspace

Return Value

string

Name of this workspace

string getTitle()

Returns the workspace title

Return Value

string

void setTitle(string $title)

Sets workspace title

Parameters

string $title

Return Value

void

string|null getDescription()

Returns the workspace description

Return Value

string|null

void setDescription(string $description)

Sets the workspace description

Parameters

string $description

Return Value

void

UserInterface|null getOwner()

Returns the workspace owner.

Return Value

UserInterface|null

void setOwner(UserInterface|string|null $user)

Returns the workspace owner.

Parameters

UserInterface|string|null $user

The new user, or user's UUID

Return Value

void

bool isPersonalWorkspace()

Checks if this workspace is a user's personal workspace

Return Value

bool

bool isPrivateWorkspace()

Checks if this workspace is shared only across users with access to internal workspaces, for example "reviewers"

Return Value

bool

bool isInternalWorkspace()

Checks if this workspace is shared across all editors

Return Value

bool

bool isPublicWorkspace()

Checks if this workspace is public to everyone, even without authentication

Return Value

bool

void setBaseWorkspace(Workspace $baseWorkspace)

Sets the base workspace

Note that this method is not part of the public API because further action is necessary for rebasing a workspace

Parameters

Workspace $baseWorkspace

Return Value

void

Workspace|null getBaseWorkspace()

Returns the base workspace, if any

Return Value

Workspace|null

array getBaseWorkspaces()

Returns all base workspaces, if any

Return Value

array

NodeData getRootNodeData()

Returns the root node data of this workspace

Return Value

NodeData

void publish(Workspace $targetWorkspace)

Publishes the content of this workspace to another workspace.

The specified workspace must be a base workspace of this workspace.

Parameters

Workspace $targetWorkspace

The workspace to publish to

Return Value

void

void publishNodes(array $nodes, Workspace $targetWorkspace)

Publishes the given nodes to the target workspace.

The specified workspace must be a base workspace of this workspace.

Parameters

array $nodes
Workspace $targetWorkspace

The workspace to publish to

Return Value

void

void publishNode(NodeInterface $nodeToPublish, Workspace $targetWorkspace)

Publishes the given node to the target workspace.

The specified workspace must be a base workspace of this workspace.

Parameters

NodeInterface $nodeToPublish

The node to publish

Workspace $targetWorkspace

The workspace to publish to

Return Value

void

protected bool publishNodeCanBeSkipped(NodeInterface $node, Workspace $targetWorkspace)

Checks if the given node can / needs to be published to the given target workspace or if that operation can be skipped.

Parameters

NodeInterface $node

The node to be published

Workspace $targetWorkspace

The target workspace

Return Value

bool

Exceptions

WorkspaceException

protected void replaceNodeData(NodeInterface $sourceNode, NodeData $targetNodeData)

Replace the node data of a node instance with a given target node data

The current node data of $node will be removed and be replaced by $targetNodeData. If $node was marked as removed, both node data instances are removed.

Parameters

NodeInterface $sourceNode

The node instance with node data to be published

NodeData $targetNodeData

The existing node data in the target workspace

Return Value

void

protected void moveNodeVariantsInOtherWorkspaces(string $nodeIdentifier, string $targetPath, Workspace $sourceWorkspace, Workspace $targetWorkspace)

Moves variants of a given node which exists in other workspaces than source and target workspace.

Parameters

string $nodeIdentifier

The node which is about to be moved

string $targetPath

The target node path the node is being moved to

Workspace $sourceWorkspace

The workspace the node is currently located

Workspace $targetWorkspace

The workspace the node is being published to

Return Value

void

protected NodeData moveTargetNodeDataToNewPosition(NodeData $targetNodeData, string $destinationPath)

Moves an existing node in a target workspace to the place it should be in after publish, in order to move all children to the new position as well.

Parameters

NodeData $targetNodeData

The (publish-) target node data to be moved

string $destinationPath

The destination path of the move

Return Value

NodeData

Either the same object like $targetNodeData, or, if $targetNodeData was transformed into a shadow node, the new target node (see move())

protected void moveNodeVariantToTargetWorkspace(NodeInterface $nodeToPublish, Workspace $targetWorkspace)

Move the given node instance to the target workspace

If no target node variant (having the same dimension values) exists in the target workspace, the node that is published will be re-used as a new node variant in the target workspace.

Parameters

NodeInterface $nodeToPublish

The node to publish

Workspace $targetWorkspace

The workspace to publish to

Return Value

void

protected void adjustShadowNodeDataForNodePublishing(NodeData $sourceNodeData, Workspace $targetWorkspace, NodeData $targetNodeData)

Adjusts related shadow nodes for a "publish node" operation.

This method will look for a shadow node of $sourceNodeData. That shadow node will either be adjusted or, if the target node in the given target workspace is marked as removed, remove it.

Parameters

NodeData $sourceNodeData

Node Data of the node to publish

Workspace $targetWorkspace

Workspace the node is going to be published to

NodeData $targetNodeData

Return Value

void

int getNodeCount()

Returns the number of nodes in this workspace.

If $includeBaseWorkspaces is enabled, also nodes of base workspaces are taken into account. If it is disabled (default) then the number of nodes is the actual number (+1) of changes related to its base workspaces.

A node count of 1 means that no changes are pending in this workspace because a workspace always contains at least its Root Node.

Return Value

int

protected void verifyPublishingTargetWorkspace(Workspace $targetWorkspace)

Checks if the specified workspace is a base workspace of this workspace and if not, throws an exception

Parameters

Workspace $targetWorkspace

The publishing target workspace

Return Value

void

Exceptions

WorkspaceException

protected NodeData|null findCorrespondingNodeDataInTargetWorkspace(NodeInterface $node, Workspace $targetWorkspace)

Returns the NodeData instance with the given identifier from the target workspace.

If no NodeData instance is found in that target workspace, null is returned.

Parameters

NodeInterface $node

The reference node to find a corresponding variant for

Workspace $targetWorkspace

The target workspace to look in

Return Value

NodeData|null

Either a regular node, a shadow node or null

protected void emitBaseWorkspaceChanged(Workspace $workspace, Workspace $oldBaseWorkspace = null, Workspace $newBaseWorkspace = null)

Emits a signal after the base workspace has been changed

Parameters

Workspace $workspace

This workspace

Workspace $oldBaseWorkspace

The workspace which was the base workspace before the change

Workspace $newBaseWorkspace

The new base workspace

Return Value

void

protected void emitBeforeNodePublishing(NodeInterface $node, Workspace $targetWorkspace)

Emits a signal just before a node is being published

The signal emits the source node and target workspace, i.e. the node contains its source workspace.

Parameters

NodeInterface $node

The node to be published

Workspace $targetWorkspace

The publishing target workspace

Return Value

void

protected void emitAfterNodePublishing(NodeInterface $node, Workspace $targetWorkspace)

Emits a signal when a node has been published.

The signal emits the source node and target workspace, i.e. the node contains its source workspace.

Parameters

NodeInterface $node

The node that was published

Workspace $targetWorkspace

The publishing target workspace

Return Value

void