You are here

class BaseEntry in Content Planner 8

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

@package Drupal\content_planner\Component

Hierarchy

  • class \Drupal\content_planner\Component\BaseEntry

Expanded class hierarchy of BaseEntry

2 files declare their use of BaseEntry
CalendarEntry.php in modules/content_calendar/src/Component/CalendarEntry.php
KanbanEntry.php in modules/content_kanban/src/Component/KanbanEntry.php

File

src/Component/BaseEntry.php, line 14

Namespace

Drupal\content_planner\Component
View source
class BaseEntry {

  /**
   * Drupal static method to retrieve the user picture url by user id.
   *
   * @param int $userId
   *   The user ID.
   * @param string $imageStyle
   *   The machine name of the image style.
   *
   * @return bool|string
   *   Returns the picture url if any, FALSE otherwise.
   */
  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];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
BaseEntry::getUserPictureFromCache public function Drupal static method to retrieve the user picture url by user id.