You are here

public function BaseEntry::getUserPictureFromCache in Content Planner 8

Drupal static method to retrieve the user picture url by user id.

Parameters

int $userId: The user ID.

string $imageStyle: The machine name of the image style.

Return value

bool|string Returns the picture url if any, FALSE otherwise.

2 calls to BaseEntry::getUserPictureFromCache()
CalendarEntry::getUserPictureURL in modules/content_calendar/src/Component/CalendarEntry.php
Get the URL of the user picture.
KanbanEntry::getUserPictureUrl in modules/content_kanban/src/Component/KanbanEntry.php
Gets the URL of the user picture.

File

src/Component/BaseEntry.php, line 27

Class

BaseEntry
Base class for Content Planner components (e.g. CalendarEntry, KanbanEntry).

Namespace

Drupal\content_planner\Component

Code

public function getUserPictureFromCache($userId, $imageStyle) {
  $pictureStyles =& drupal_static(__METHOD__, []);
  if (!isset($pictureStyles[$imageStyle][$userId])) {
    $styleUrl = FALSE;

    // If a user picture is not in the static cache, then create one.
    $user = User::load($userId);
    if ($user instanceof UserInterface) {
      $styleUrl = UserProfileImage::generateProfileImageUrl($user, $imageStyle);
    }
    $pictureStyles[$imageStyle][$userId] = $styleUrl;
  }
  return $pictureStyles[$imageStyle][$userId];
}