You are here

public function SocialPostHelper::buildCurrentUserImage in Open Social 10.0.x

Same name and namespace in other branches
  1. 10.3.x modules/social_features/social_post/src/Service/SocialPostHelper.php \Drupal\social_post\Service\SocialPostHelper::buildCurrentUserImage()
  2. 10.1.x modules/social_features/social_post/src/Service/SocialPostHelper.php \Drupal\social_post\Service\SocialPostHelper::buildCurrentUserImage()
  3. 10.2.x modules/social_features/social_post/src/Service/SocialPostHelper.php \Drupal\social_post\Service\SocialPostHelper::buildCurrentUserImage()

Gets image of the user profile.

Return value

array|null The renderable data.

Overrides SocialPostHelperInterface::buildCurrentUserImage

File

modules/social_features/social_post/src/Service/SocialPostHelper.php, line 48

Class

SocialPostHelper
Class SocialPostHelper.

Namespace

Drupal\social_post\Service

Code

public function buildCurrentUserImage() {
  $storage = $this->entityTypeManager
    ->getStorage('profile');
  if (!empty($storage)) {

    // Load current user.
    $account = $this->currentUser
      ->getAccount();
    if ($user_profile = $storage
      ->loadByUser($account, 'profile')) {

      // Load compact notification view mode of the attached profile.
      return $this->entityTypeManager
        ->getViewBuilder('profile')
        ->view($user_profile, 'compact_notification');
    }
  }
  return NULL;
}