3 namespace Drupal\workspaces;
5 use Drupal\Core\Entity\EntityTypeInterface;
8 * Provides an interface for managing Workspaces.
10 interface WorkspaceManagerInterface {
13 * Returns whether an entity type can belong to a workspace or not.
15 * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
16 * The entity type to check.
19 * TRUE if the entity type can belong to a workspace, FALSE otherwise.
21 public function isEntityTypeSupported(EntityTypeInterface $entity_type);
24 * Returns an array of entity types that can belong to workspaces.
26 * @return \Drupal\Core\Entity\EntityTypeInterface[]
27 * The entity types what can belong to workspaces.
29 public function getSupportedEntityTypes();
32 * Gets the active workspace.
34 * @return \Drupal\workspaces\WorkspaceInterface
35 * The active workspace entity object.
37 public function getActiveWorkspace();
40 * Sets the active workspace via the workspace negotiators.
42 * @param \Drupal\workspaces\WorkspaceInterface $workspace
43 * The workspace to set as active.
47 * @throws \Drupal\workspaces\WorkspaceAccessException
48 * Thrown when the current user doesn't have access to view the workspace.
50 public function setActiveWorkspace(WorkspaceInterface $workspace);
53 * Executes the given callback function in the context of a workspace.
55 * @param string $workspace_id
56 * The ID of a workspace.
57 * @param callable $function
58 * The callback to be executed.
61 * The callable's return value.
63 public function executeInWorkspace($workspace_id, callable $function);
66 * Determines whether runtime entity operations should be altered.
68 * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
69 * The entity type to check.
72 * TRUE if the entity operations or queries should be altered in the current
73 * request, FALSE otherwise.
75 public function shouldAlterOperations(EntityTypeInterface $entity_type);