Chris@17
|
1 <?php
|
Chris@17
|
2
|
Chris@17
|
3 namespace Drupal\workspaces;
|
Chris@17
|
4
|
Chris@17
|
5 use Drupal\Core\Entity\EntityTypeInterface;
|
Chris@17
|
6
|
Chris@17
|
7 /**
|
Chris@17
|
8 * Provides an interface for managing Workspaces.
|
Chris@17
|
9 */
|
Chris@17
|
10 interface WorkspaceManagerInterface {
|
Chris@17
|
11
|
Chris@17
|
12 /**
|
Chris@17
|
13 * Returns whether an entity type can belong to a workspace or not.
|
Chris@17
|
14 *
|
Chris@17
|
15 * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
|
Chris@17
|
16 * The entity type to check.
|
Chris@17
|
17 *
|
Chris@17
|
18 * @return bool
|
Chris@17
|
19 * TRUE if the entity type can belong to a workspace, FALSE otherwise.
|
Chris@17
|
20 */
|
Chris@17
|
21 public function isEntityTypeSupported(EntityTypeInterface $entity_type);
|
Chris@17
|
22
|
Chris@17
|
23 /**
|
Chris@17
|
24 * Returns an array of entity types that can belong to workspaces.
|
Chris@17
|
25 *
|
Chris@17
|
26 * @return \Drupal\Core\Entity\EntityTypeInterface[]
|
Chris@17
|
27 * The entity types what can belong to workspaces.
|
Chris@17
|
28 */
|
Chris@17
|
29 public function getSupportedEntityTypes();
|
Chris@17
|
30
|
Chris@17
|
31 /**
|
Chris@17
|
32 * Gets the active workspace.
|
Chris@17
|
33 *
|
Chris@17
|
34 * @return \Drupal\workspaces\WorkspaceInterface
|
Chris@17
|
35 * The active workspace entity object.
|
Chris@17
|
36 */
|
Chris@17
|
37 public function getActiveWorkspace();
|
Chris@17
|
38
|
Chris@17
|
39 /**
|
Chris@17
|
40 * Sets the active workspace via the workspace negotiators.
|
Chris@17
|
41 *
|
Chris@17
|
42 * @param \Drupal\workspaces\WorkspaceInterface $workspace
|
Chris@17
|
43 * The workspace to set as active.
|
Chris@17
|
44 *
|
Chris@17
|
45 * @return $this
|
Chris@17
|
46 *
|
Chris@17
|
47 * @throws \Drupal\workspaces\WorkspaceAccessException
|
Chris@17
|
48 * Thrown when the current user doesn't have access to view the workspace.
|
Chris@17
|
49 */
|
Chris@17
|
50 public function setActiveWorkspace(WorkspaceInterface $workspace);
|
Chris@17
|
51
|
Chris@17
|
52 /**
|
Chris@17
|
53 * Executes the given callback function in the context of a workspace.
|
Chris@17
|
54 *
|
Chris@17
|
55 * @param string $workspace_id
|
Chris@17
|
56 * The ID of a workspace.
|
Chris@17
|
57 * @param callable $function
|
Chris@17
|
58 * The callback to be executed.
|
Chris@17
|
59 *
|
Chris@17
|
60 * @return mixed
|
Chris@17
|
61 * The callable's return value.
|
Chris@17
|
62 */
|
Chris@17
|
63 public function executeInWorkspace($workspace_id, callable $function);
|
Chris@17
|
64
|
Chris@17
|
65 /**
|
Chris@17
|
66 * Determines whether runtime entity operations should be altered.
|
Chris@17
|
67 *
|
Chris@17
|
68 * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
|
Chris@17
|
69 * The entity type to check.
|
Chris@17
|
70 *
|
Chris@17
|
71 * @return bool
|
Chris@17
|
72 * TRUE if the entity operations or queries should be altered in the current
|
Chris@17
|
73 * request, FALSE otherwise.
|
Chris@17
|
74 */
|
Chris@17
|
75 public function shouldAlterOperations(EntityTypeInterface $entity_type);
|
Chris@17
|
76
|
Chris@17
|
77 }
|