function _social_group_get_join_methods in Open Social 8.9
Same name and namespace in other branches
- 8.6 modules/social_features/social_group/social_group.module \_social_group_get_join_methods()
- 8.7 modules/social_features/social_group/social_group.module \_social_group_get_join_methods()
- 8.8 modules/social_features/social_group/social_group.module \_social_group_get_join_methods()
- 10.3.x modules/social_features/social_group/social_group.module \_social_group_get_join_methods()
- 10.0.x modules/social_features/social_group/social_group.module \_social_group_get_join_methods()
- 10.1.x modules/social_features/social_group/social_group.module \_social_group_get_join_methods()
- 10.2.x modules/social_features/social_group/social_group.module \_social_group_get_join_methods()
Get the join methods of a group.
Parameters
\Drupal\group\Entity\GroupInterface $group: the Group interface.
Return value
array Returns join methods of a group.
2 calls to _social_group_get_join_methods()
- social_group_preprocess_group in modules/
social_features/ social_group/ social_group.module - Prepares variables for profile templates.
- social_group_preprocess_group__hero in modules/
social_features/ social_group/ social_group.module - Implements hook_preprocess_HOOK().
File
- modules/
social_features/ social_group/ social_group.module, line 374 - The Social group module.
Code
function _social_group_get_join_methods(GroupInterface $group) {
$group_type = $group
->getGroupType();
$group_type_id = $group_type
->id();
$join_methods = [];
// Get join method based on group type. TODO get it programmatically.
switch ($group_type_id) {
case 'secret_group':
case 'closed_group':
$join_methods = [
'added' => t('Be added by group managers'),
];
break;
case 'public_group':
case 'open_group':
$join_methods = [
'direct' => t('Free to join'),
'added' => t('Be added by group managers'),
];
break;
case 'flexible_group':
// Try to retrieve join methods from Group directly.
$allowed_options = $group
->get('field_group_allowed_join_method')
->getValue();
foreach ($allowed_options as $option) {
$value = $option['value'];
if ($value === 'direct') {
$join_methods['direct'] = t('Free to join');
}
if ($value === 'added') {
$join_methods['added'] = t('Be added by group managers');
}
}
break;
}
return $join_methods;
}