function _social_profile_get_contact_url in Open Social 8.3
Same name and namespace in other branches
- 8.9 modules/social_features/social_profile/social_profile.module \_social_profile_get_contact_url()
- 8 modules/social_features/social_profile/social_profile.module \_social_profile_get_contact_url()
- 8.2 modules/social_features/social_profile/social_profile.module \_social_profile_get_contact_url()
- 8.4 modules/social_features/social_profile/social_profile.module \_social_profile_get_contact_url()
- 8.5 modules/social_features/social_profile/social_profile.module \_social_profile_get_contact_url()
- 8.6 modules/social_features/social_profile/social_profile.module \_social_profile_get_contact_url()
- 8.7 modules/social_features/social_profile/social_profile.module \_social_profile_get_contact_url()
- 8.8 modules/social_features/social_profile/social_profile.module \_social_profile_get_contact_url()
- 10.3.x modules/social_features/social_profile/social_profile.module \_social_profile_get_contact_url()
- 10.0.x modules/social_features/social_profile/social_profile.module \_social_profile_get_contact_url()
- 10.1.x modules/social_features/social_profile/social_profile.module \_social_profile_get_contact_url()
- 10.2.x modules/social_features/social_profile/social_profile.module \_social_profile_get_contact_url()
Get the contact URL. This can be private message or other means of contact.
Parameters
\Drupal\user\Entity\User $account: The user object.
Return value
\Drupal\Core\Url The URL to contact the user.
1 call to _social_profile_get_contact_url()
- social_profile_preprocess_profile in modules/
social_features/ social_profile/ social_profile.module - Prepares variables for profile templates.
File
- modules/
social_features/ social_profile/ social_profile.module, line 386 - The Social profile module.
Code
function _social_profile_get_contact_url(User $account) {
if (\Drupal::moduleHandler()
->moduleExists('social_private_message')) {
$current_user = \Drupal::currentUser();
if ($current_user
->hasPermission('use private messaging system') && $current_user
->id() != $account
->id()) {
$members = [
$current_user,
$account,
];
$thread_id = \Drupal::service('private_message.mapper')
->getThreadIdForMembers($members);
if ($thread_id) {
return Url::fromRoute('entity.private_message_thread.canonical', [
'private_message_thread' => $thread_id,
], [
'attributes' => [
'class' => [
'private_message_link',
],
],
]);
}
else {
return Url::fromRoute('private_message.private_message_create', [], [
'query' => [
'recipient' => $account
->id(),
],
]);
}
}
}
return Url::fromUserInput('/user/' . $account
->id() . '/information');
}