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