interface WorkspaceAssociationInterface (View source)

internal  
 

Defines an interface for the workspace_association service.

The canonical workspace association data is stored in a revision metadata field on each entity revision that is tracked by a workspace.

For the purpose of optimizing workspace-specific queries, the default implementation of this interface defines a custom 'workspace_association' index table which stores only the latest revisions tracked by a workspace.

Methods

trackEntity(RevisionableInterface $entity, WorkspaceInterface $workspace)

Updates or creates the association for a given entity and a workspace.

workspaceInsert(WorkspaceInterface $workspace)

Responds to the creation of a new workspace entity.

array
getTrackedEntities(string $workspace_id, string|null $entity_type_id = NULL, int[]|string[]|null $entity_ids = NULL)

Retrieves the entities tracked by a given workspace.

array
getAssociatedRevisions(string $workspace_id, string $entity_type_id, int[]|string[]|null $entity_ids = NULL)

Retrieves all content revisions tracked by a given workspace.

string[]
getEntityTrackingWorkspaceIds(RevisionableInterface $entity)

Gets a list of workspace IDs in which an entity is tracked.

postPublish(WorkspaceInterface $workspace)

Triggers clean-up operations after publishing a workspace.

deleteAssociations(string $workspace_id, string|null $entity_type_id = NULL, string|null $entity_ids = NULL)

Deletes all the workspace association records for the given workspace.

initializeWorkspace(WorkspaceInterface $workspace)

Initializes a workspace with all the associations of its parent.

Details

trackEntity(RevisionableInterface $entity, WorkspaceInterface $workspace)

Updates or creates the association for a given entity and a workspace.

Parameters

RevisionableInterface $entity

The entity to update or create from.

WorkspaceInterface $workspace

The workspace in which the entity will be tracked.

workspaceInsert(WorkspaceInterface $workspace)

Responds to the creation of a new workspace entity.

Parameters

WorkspaceInterface $workspace

The workspaces that was inserted.

array getTrackedEntities(string $workspace_id, string|null $entity_type_id = NULL, int[]|string[]|null $entity_ids = NULL)

Retrieves the entities tracked by a given workspace.

Parameters

string $workspace_id

The ID of the workspace.

string|null $entity_type_id

(optional) An entity type ID to filter the results by. Defaults to NULL.

int[]|string[]|null $entity_ids

(optional) An array of entity IDs to filter the results by. Defaults to NULL.

Return Value

array

Returns a multidimensional array where the first level keys are entity type IDs and the values are an array of entity IDs keyed by revision IDs.

array getAssociatedRevisions(string $workspace_id, string $entity_type_id, int[]|string[]|null $entity_ids = NULL)

Retrieves all content revisions tracked by a given workspace.

Since the 'workspace_association' index table only tracks the latest associated revisions, this method retrieves all the tracked revisions by querying the entity type's revision table directly.

Parameters

string $workspace_id

The ID of the workspace.

string $entity_type_id

An entity type ID to find revisions for.

int[]|string[]|null $entity_ids

(optional) An array of entity IDs to filter the results by. Defaults to NULL.

Return Value

array

Returns an array where the values are an array of entity IDs keyed by revision IDs.

string[] getEntityTrackingWorkspaceIds(RevisionableInterface $entity)

Gets a list of workspace IDs in which an entity is tracked.

Parameters

RevisionableInterface $entity

An entity object.

Return Value

string[]

An array of workspace IDs where the given entity is tracked, or an empty array if it is not tracked anywhere.

postPublish(WorkspaceInterface $workspace)

Triggers clean-up operations after publishing a workspace.

Parameters

WorkspaceInterface $workspace

A workspace entity.

deleteAssociations(string $workspace_id, string|null $entity_type_id = NULL, string|null $entity_ids = NULL)

Deletes all the workspace association records for the given workspace.

Parameters

string $workspace_id

A workspace entity ID.

string|null $entity_type_id

(optional) The target entity type of the associations to delete. Defaults to NULL.

string|null $entity_ids

(optional) The target entity IDs of the associations to delete. Defaults to NULL.

initializeWorkspace(WorkspaceInterface $workspace)

Initializes a workspace with all the associations of its parent.

Parameters

WorkspaceInterface $workspace

The workspace to be initialized.