function QueryParameterWorkspaceNegotiator::getActiveWorkspace

Same name in other branches
  1. 9 core/modules/workspaces/src/Negotiator/QueryParameterWorkspaceNegotiator.php \Drupal\workspaces\Negotiator\QueryParameterWorkspaceNegotiator::getActiveWorkspace()

Overrides SessionWorkspaceNegotiator::getActiveWorkspace

File

core/modules/workspaces/src/Negotiator/QueryParameterWorkspaceNegotiator.php, line 22

Class

QueryParameterWorkspaceNegotiator
Defines the query parameter workspace negotiator.

Namespace

Drupal\workspaces\Negotiator

Code

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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.