function social_core_social_user_account_header_items_alter in Open Social 10.2.x
Same name and namespace in other branches
- 8.9 modules/social_features/social_core/social_core.module \social_core_social_user_account_header_items_alter()
- 10.3.x modules/social_features/social_core/social_core.module \social_core_social_user_account_header_items_alter()
- 10.0.x modules/social_features/social_core/social_core.module \social_core_social_user_account_header_items_alter()
- 10.1.x modules/social_features/social_core/social_core.module \social_core_social_user_account_header_items_alter()
Implements hook_social_user_account_header_items().
Adds an indicator to the user account menu.
File
- modules/
social_features/ social_core/ social_core.module, line 222 - The Social core module.
Code
function social_core_social_user_account_header_items_alter(array &$menu_links, array $context) {
// We require a logged in user for this indicator.
if (empty($context['user']) || !$context['user']
->isAuthenticated()) {
return;
}
// If the account_box link was removed we have nothing to do.
if (!isset($menu_links['account_box'])) {
return;
}
// Get the total amount of notifications for the user.
/** @var \Drupal\social_core\InviteService $core_invites */
$core_invites = \Drupal::service('social_core.invite');
// Only when there are actual Invites.
if ($core_invites
->getInviteData('amount') > 0) {
$menu_links['account_box']['#wrapper_attributes']['class'][] = 'has-alert has-alert--desktop';
}
}