public function OgGroupContextCacheContext::getContext in Organic groups 8
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
- src/
Cache/ Context/ OgGroupContextCacheContext.php, line 55
Class
- OgGroupContextCacheContext
- Defines a cache context service for the currently active group.
Namespace
Drupal\og\Cache\ContextCode
public function getContext() {
// Do not provide a cache context if there is no group in the current
// context.
$group = $this->ogContext
->getGroup();
if (empty($group)) {
return self::NO_CONTEXT;
}
// Compose a cache context string that consists of the entity type ID and
// the entity ID of the active group.
return implode(':', [
$group
->getEntityTypeId(),
$group
->id(),
]);
}