function WorkspaceManager::setActiveWorkspace
Same name and namespace in other branches
- 11.x core/modules/workspaces/src/WorkspaceManager.php \Drupal\workspaces\WorkspaceManager::setActiveWorkspace()
- 10 core/modules/workspaces/src/WorkspaceManager.php \Drupal\workspaces\WorkspaceManager::setActiveWorkspace()
- 9 core/modules/workspaces/src/WorkspaceManager.php \Drupal\workspaces\WorkspaceManager::setActiveWorkspace()
- 8.9.x core/modules/workspaces/src/WorkspaceManager.php \Drupal\workspaces\WorkspaceManager::setActiveWorkspace()
Sets the active workspace.
Parameters
\Drupal\workspaces\WorkspaceInterface $workspace: The workspace to set as active.
bool $persist: (optional) Whether to persist this workspace in the first applicable negotiator. Defaults to TRUE.
Return value
$this
Overrides WorkspaceManagerInterface::setActiveWorkspace
File
-
core/
modules/ workspaces/ src/ WorkspaceManager.php, line 80
Class
- WorkspaceManager
- Provides the workspace manager.
Namespace
Drupal\workspacesCode
public function setActiveWorkspace(WorkspaceInterface $workspace, bool $persist = TRUE) {
$this->doSwitchWorkspace($workspace);
// Set the workspace on the first applicable negotiator.
if ($persist) {
$request = $this->requestStack
->getCurrentRequest();
foreach ($this->negotiators as $negotiator) {
if ($negotiator->applies($request)) {
$negotiator->setActiveWorkspace($workspace);
break;
}
}
}
return $this;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.