You are here

public function DefaultWorkspaceNegotiator::getActiveWorkspace in Workspace 8.2

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\workspace\WorkspaceInterface|null The negotiated workspace or NULL if the negotiator could not determine a valid workspace.

Overrides WorkspaceNegotiatorInterface::getActiveWorkspace

File

src/Negotiator/DefaultWorkspaceNegotiator.php, line 49

Class

DefaultWorkspaceNegotiator
Defines the default workspace negotiator.

Namespace

Drupal\workspace\Negotiator

Code

public function getActiveWorkspace(Request $request) {
  if (!$this->defaultWorkspace) {
    $default_workspace = $this->workspaceStorage
      ->create([
      'id' => WorkspaceInterface::DEFAULT_WORKSPACE,
      'label' => Unicode::ucwords(WorkspaceInterface::DEFAULT_WORKSPACE),
      'target' => '',
    ]);
    $default_workspace
      ->enforceIsNew(FALSE);
    $this->defaultWorkspace = $default_workspace;
  }
  return $this->defaultWorkspace;
}