function social_group_social_user_account_header_create_links in Open Social 8.9
Same name and namespace in other branches
- 8.4 modules/social_features/social_group/social_group.module \social_group_social_user_account_header_create_links()
- 8.5 modules/social_features/social_group/social_group.module \social_group_social_user_account_header_create_links()
- 8.6 modules/social_features/social_group/social_group.module \social_group_social_user_account_header_create_links()
- 8.7 modules/social_features/social_group/social_group.module \social_group_social_user_account_header_create_links()
- 8.8 modules/social_features/social_group/social_group.module \social_group_social_user_account_header_create_links()
- 10.3.x modules/social_features/social_group/social_group.module \social_group_social_user_account_header_create_links()
- 10.0.x modules/social_features/social_group/social_group.module \social_group_social_user_account_header_create_links()
- 10.1.x modules/social_features/social_group/social_group.module \social_group_social_user_account_header_create_links()
- 10.2.x modules/social_features/social_group/social_group.module \social_group_social_user_account_header_create_links()
Implements hook_social_user_account_header_create_links().
Adds the "Create Group" link to the content creation menu. When the user can only create groups of one type, the user skips the group type selection page.
File
- modules/
social_features/ social_group/ social_group.module, line 1909 - The Social group module.
Code
function social_group_social_user_account_header_create_links($context) {
// Create url to create a group.
$route_add_group = Url::fromRoute('entity.group.add_page');
// If we have a user to work with, we can check if we should redirect it to
// the create group overview or a single group.
// If we do not have a user we'll default to the overview.
if (!empty($context['user'])) {
/** @var \Drupal\Core\Session\AccountInterface $user */
$account = $context['user'];
$route_add_group = \Drupal::service('social_group.helper_service')
->getGroupsToAddUrl($account) ?? $route_add_group;
}
return [
'add_group' => [
'#type' => 'link',
'#attributes' => [
'title' => new TranslatableMarkup('Create New Group'),
],
'#title' => new TranslatableMarkup('New Group'),
'#weight' => 500,
] + $route_add_group
->toRenderArray(),
];
}