function WorkspaceManager::executeOutsideWorkspace
Executes the given callback function without any workspace context.
Parameters
callable $function: The callback to be executed.
Return value
mixed The callable's return value.
Overrides WorkspaceManagerInterface::executeOutsideWorkspace
File
-
core/
modules/ workspaces/ src/ WorkspaceManager.php, line 197
Class
- WorkspaceManager
- Provides the workspace manager.
Namespace
Drupal\workspacesCode
public function executeOutsideWorkspace(callable $function) {
$previous_active_workspace = $this->getActiveWorkspace();
// Switch to Live if we're in a workspace.
if ($previous_active_workspace) {
$this->doSwitchWorkspace(NULL);
}
$result = $function();
// Switch back if needed.
if ($previous_active_workspace) {
$this->doSwitchWorkspace($previous_active_workspace);
}
return $result;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.