a3f0e3b87d98b29c0e3e47834e38eab7427e9015
[yaffs-website] / web / core / modules / workspaces / src / Negotiator / WorkspaceNegotiatorInterface.php
1 <?php
2
3 namespace Drupal\workspaces\Negotiator;
4
5 use Drupal\workspaces\WorkspaceInterface;
6 use Symfony\Component\HttpFoundation\Request;
7
8 /**
9  * Workspace negotiators provide a way to get the active workspace.
10  *
11  * \Drupal\workspaces\WorkspaceManager acts as the service collector for
12  * Workspace negotiators.
13  */
14 interface WorkspaceNegotiatorInterface {
15
16   /**
17    * Checks whether the negotiator applies to the current request or not.
18    *
19    * @param \Symfony\Component\HttpFoundation\Request $request
20    *   The HTTP request.
21    *
22    * @return bool
23    *   TRUE if the negotiator applies for the current request, FALSE otherwise.
24    */
25   public function applies(Request $request);
26
27   /**
28    * Gets the negotiated workspace, if any.
29    *
30    * Note that it is the responsibility of each implementation to check whether
31    * the negotiated workspace actually exists in the storage.
32    *
33    * @param \Symfony\Component\HttpFoundation\Request $request
34    *   The HTTP request.
35    *
36    * @return \Drupal\workspaces\WorkspaceInterface|null
37    *   The negotiated workspace or NULL if the negotiator could not determine a
38    *   valid workspace.
39    */
40   public function getActiveWorkspace(Request $request);
41
42   /**
43    * Sets the negotiated workspace.
44    *
45    * @param \Drupal\workspaces\WorkspaceInterface $workspace
46    *   The workspace entity.
47    */
48   public function setActiveWorkspace(WorkspaceInterface $workspace);
49
50 }