You are here

public function WorkspaceManager::getActiveWorkspaceId in Multiversion 8

Fetches the currently active workspace ID.

Return value

int The active workspace ID.

Overrides WorkspaceManagerInterface::getActiveWorkspaceId

1 call to WorkspaceManager::getActiveWorkspaceId()
WorkspaceManager::getActiveWorkspace in src/Workspace/WorkspaceManager.php
@todo {@link https://www.drupal.org/node/2600382 Access check.}

File

src/Workspace/WorkspaceManager.php, line 109

Class

WorkspaceManager

Namespace

Drupal\multiversion\Workspace

Code

public function getActiveWorkspaceId() {
  $request = $this->requestStack
    ->getCurrentRequest();
  if (empty($request)) {
    return $this->container
      ->getParameter('workspace.default');
  }
  foreach ($this
    ->getSortedNegotiators() as $negotiator) {
    if ($negotiator
      ->applies($request)) {
      if ($workspace_id = $negotiator
        ->getWorkspaceId($request)) {
        return $workspace_id;
      }
    }
  }
}