public function QueryParameterWorkspaceNegotiator::getActiveWorkspace in Drupal 9
Same name and namespace in other branches
- 8 core/modules/workspaces/src/Negotiator/QueryParameterWorkspaceNegotiator.php \Drupal\workspaces\Negotiator\QueryParameterWorkspaceNegotiator::getActiveWorkspace()
Gets the negotiated workspace, if any.
Note that it is the responsibility of each implementation to check whether the negotiated workspace actually exists in the storage.
Parameters
\Symfony\Component\HttpFoundation\Request $request: The HTTP request.
Return value
\Drupal\workspaces\WorkspaceInterface|null The negotiated workspace or NULL if the negotiator could not determine a valid workspace.
Overrides SessionWorkspaceNegotiator::getActiveWorkspace
File
- core/
modules/ workspaces/ src/ Negotiator/ QueryParameterWorkspaceNegotiator.php, line 22
Class
- QueryParameterWorkspaceNegotiator
- Defines the query parameter workspace negotiator.
Namespace
Drupal\workspaces\NegotiatorCode
public function getActiveWorkspace(Request $request) {
$workspace_id = $request->query
->get('workspace');
if ($workspace_id && ($workspace = $this->workspaceStorage
->load($workspace_id))) {
$this
->setActiveWorkspace($workspace);
return $workspace;
}
return NULL;
}