class WorkspaceAssociation implements WorkspaceAssociationInterface (View source)

Provides a class for CRUD operations on workspace associations.

Constants

TABLE

The table for the workspace association storage.

Properties

protected Connection $database

The database connection.

protected EntityTypeManagerInterface $entityTypeManager

The entity type manager.

protected WorkspaceRepositoryInterface $workspaceRepository

The workspace repository service.

Methods

__construct(Connection $connection, EntityTypeManagerInterface $entity_type_manager, WorkspaceRepositoryInterface $workspace_repository)

Constructs a WorkspaceAssociation object.

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, int[]|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

__construct(Connection $connection, EntityTypeManagerInterface $entity_type_manager, WorkspaceRepositoryInterface $workspace_repository)

Constructs a WorkspaceAssociation object.

Parameters

Connection $connection

A database connection for reading and writing path aliases.

EntityTypeManagerInterface $entity_type_manager

The entity type manager for querying revisions.

WorkspaceRepositoryInterface $workspace_repository

The Workspace repository service.

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, int[]|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.

int[]|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.