class WorkspaceRepository implements WorkspaceRepositoryInterface (View source)

Provides the default workspace tree lookup operations.

Properties

protected EntityTypeManagerInterface $entityTypeManager

The entity type manager service.

protected CacheBackendInterface $cache

The cache backend used to store the workspace tree.

protected array|null $tree

An array of tree items, keyed by workspace IDs and sorted in tree order.

Methods

__construct(EntityTypeManagerInterface $entity_type_manager, CacheBackendInterface $cache_backend)

Constructs a new WorkspaceRepository instance.

array
loadTree()

Returns an array of workspaces tree item properties, sorted in tree order.

string[]
getDescendantsAndSelf(string $workspace_id)

Returns the descendant IDs of the passed-in workspace, including itself.

$this
resetCache()

Resets the cached workspace tree.

Details

__construct(EntityTypeManagerInterface $entity_type_manager, CacheBackendInterface $cache_backend)

Constructs a new WorkspaceRepository instance.

Parameters

EntityTypeManagerInterface $entity_type_manager

The entity type manager service.

CacheBackendInterface $cache_backend

The cache backend.

array loadTree()

Returns an array of workspaces tree item properties, sorted in tree order.

Return Value

array

An array of workspace tree item properties, keyed by the workspace IDs. The tree item properties are:

  • depth: The depth of the workspace in the tree;
  • ancestors: The ancestor IDs of the workspace;
  • descendants: The descendant IDs of the workspace.

string[] getDescendantsAndSelf(string $workspace_id)

Returns the descendant IDs of the passed-in workspace, including itself.

Parameters

string $workspace_id

A workspace ID.

Return Value

string[]

An array of descendant workspace IDs, including the passed-in one.

$this resetCache()

Resets the cached workspace tree.

Return Value

$this