public function SocialGroupJoinMethodCacheContext::getContext in Open Social 10.1.x
Same name and namespace in other branches
- 8.9 modules/social_features/social_group/src/CacheContext/SocialGroupJoinMethodCacheContext.php \Drupal\social_group\CacheContext\SocialGroupJoinMethodCacheContext::getContext()
- 10.3.x modules/social_features/social_group/src/CacheContext/SocialGroupJoinMethodCacheContext.php \Drupal\social_group\CacheContext\SocialGroupJoinMethodCacheContext::getContext()
- 10.0.x modules/social_features/social_group/src/CacheContext/SocialGroupJoinMethodCacheContext.php \Drupal\social_group\CacheContext\SocialGroupJoinMethodCacheContext::getContext()
- 10.2.x modules/social_features/social_group/src/CacheContext/SocialGroupJoinMethodCacheContext.php \Drupal\social_group\CacheContext\SocialGroupJoinMethodCacheContext::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
- modules/
social_features/ social_group/ src/ CacheContext/ SocialGroupJoinMethodCacheContext.php, line 24
Class
- SocialGroupJoinMethodCacheContext
- Class SocialGroupJoinMethodCacheContext.
Namespace
Drupal\social_group\CacheContextCode
public function getContext() {
// This will return the join method of the current group.
$group = _social_group_get_current_group();
if ($group instanceof Group && $group
->hasField('field_group_allowed_join_method')) {
if (!empty($group
->getFieldValue('field_group_allowed_join_method', 'value'))) {
return $group
->getFieldValue('field_group_allowed_join_method', 'value');
}
}
}