You are here

public function WorkspaceCacheContext::getContext in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/workspaces/src/WorkspaceCacheContext.php \Drupal\workspaces\WorkspaceCacheContext::getContext()
  2. 9 core/modules/workspaces/src/WorkspaceCacheContext.php \Drupal\workspaces\WorkspaceCacheContext::getContext()

Returns the string representation of the cache context.

A cache context service's name is used as a token (placeholder) cache key, and is then replaced with the string returned by this method.

Return value

string The string representation of the cache context.

Overrides CacheContextInterface::getContext

File

core/modules/workspaces/src/WorkspaceCacheContext.php, line 42

Class

WorkspaceCacheContext
Defines the WorkspaceCacheContext service, for "per workspace" caching.

Namespace

Drupal\workspaces

Code

public function getContext() {
  return $this->workspaceManager
    ->hasActiveWorkspace() ? $this->workspaceManager
    ->getActiveWorkspace()
    ->id() : 'live';
}