class SocialGroupJoinMethodCacheContext in Open Social 10.2.x
Same name and namespace in other branches
- 8.9 modules/social_features/social_group/src/CacheContext/SocialGroupJoinMethodCacheContext.php \Drupal\social_group\CacheContext\SocialGroupJoinMethodCacheContext
- 10.3.x modules/social_features/social_group/src/CacheContext/SocialGroupJoinMethodCacheContext.php \Drupal\social_group\CacheContext\SocialGroupJoinMethodCacheContext
- 10.0.x modules/social_features/social_group/src/CacheContext/SocialGroupJoinMethodCacheContext.php \Drupal\social_group\CacheContext\SocialGroupJoinMethodCacheContext
- 10.1.x modules/social_features/social_group/src/CacheContext/SocialGroupJoinMethodCacheContext.php \Drupal\social_group\CacheContext\SocialGroupJoinMethodCacheContext
Class SocialGroupJoinMethodCacheContext.
Hierarchy
- class \Drupal\social_group\CacheContext\SocialGroupJoinMethodCacheContext implements CacheContextInterface
Expanded class hierarchy of SocialGroupJoinMethodCacheContext
1 string reference to 'SocialGroupJoinMethodCacheContext'
- social_group.services.yml in modules/
social_features/ social_group/ social_group.services.yml - modules/social_features/social_group/social_group.services.yml
1 service uses SocialGroupJoinMethodCacheContext
- cache_context.social_group_join_method in modules/
social_features/ social_group/ social_group.services.yml - Drupal\social_group\CacheContext\SocialGroupJoinMethodCacheContext
File
- modules/
social_features/ social_group/ src/ CacheContext/ SocialGroupJoinMethodCacheContext.php, line 12
Namespace
Drupal\social_group\CacheContextView source
class SocialGroupJoinMethodCacheContext implements CacheContextInterface {
/**
* {@inheritdoc}
*/
public static function getLabel() {
\Drupal::messenger()
->addMessage('Cache context for the join methods');
}
/**
* {@inheritdoc}
*/
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');
}
}
}
/**
* {@inheritdoc}
*/
public function getCacheableMetadata() {
return new CacheableMetadata();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
SocialGroupJoinMethodCacheContext:: |
public | function |
Gets the cacheability metadata for the context. Overrides CacheContextInterface:: |
|
SocialGroupJoinMethodCacheContext:: |
public | function |
Returns the string representation of the cache context. Overrides CacheContextInterface:: |
|
SocialGroupJoinMethodCacheContext:: |
public static | function |
Returns the label of the cache context. Overrides CacheContextInterface:: |