protected function DisqusCommentManager::ssoUserData in Disqus 8
Assembles user-specific data used by Disqus SSO.
Return value
array An array containing sso user data.
1 call to DisqusCommentManager::ssoUserData()
- DisqusCommentManager::ssoSettings in src/
DisqusCommentManager.php - Computes the full settings associated with Disqus SSO.
File
- src/
DisqusCommentManager.php, line 172
Class
- DisqusCommentManager
- It contains common functions to manage disqus_comment fields.
Namespace
Drupal\disqusCode
protected function ssoUserData() {
$account = $this->currentUser;
$data = [];
if (!$account
->isAnonymous()) {
$data['id'] = $account
->id();
$data['username'] = $account
->getAccountName();
$data['email'] = $account
->getEmail();
$data['url'] = Url::fromRoute('entity.user.canonical', [
'user' => $account
->id(),
], [
'absolute' => TRUE,
])
->toString();
// Load the user's avatar.
$user_picture_default = $this->configFactory
->get('field.instance.user.user.user_picture')
->get('settings.default_image');
$user = $this->entityTypeManager
->getStorage('user')
->load($account
->id());
if (isset($user->user_picture->target_id) && !empty($user->user_picture
->isEmpty()) && ($file = $this->entityTypeManager
->getStorage('file')
->load($user->user_picture->entity
->getFileUri()))) {
$file_uri = $file
->getFileUri();
$data['avatar'] = !empty($file_uri) ? $file_uri : NULL;
}
elseif (!empty($user_picture_default['fid']) && ($file = $this->entityTypeManager
->getStorage('file')
->load($user_picture_default['fid']))) {
$file_uri = $file
->getFileUri();
$data['avatar'] = !empty($file_uri) ? $file_uri : NULL;
}
if (isset($data['avatar'])) {
$data['avatar'] = file_create_url($data['avatar']);
}
}
$this->moduleHandler
->alter('disqus_user_data', $data);
return $data;
}