You are here

public function UserNotificationSettings::getSettings in Comment Notify 8

Get the notification preferences for a specific user.

Parameters

int $uid: The user id.

Return value

array|null array if found, else NULL

1 call to UserNotificationSettings::getSettings()
UserNotificationSettings::getSetting in src/UserNotificationSettings.php
Get a user's default preference.

File

src/UserNotificationSettings.php, line 48

Class

UserNotificationSettings
Defines the Comment notify user settings.

Namespace

Drupal\comment_notify

Code

public function getSettings($uid) {

  //$users = &drupal_static(__FUNCTION__);
  if (!isset($users[$uid])) {
    if (is_null($uid)) {
      throw new \Exception('Cannot get user preference, uid missing');
    }

    // Handle anonymous users with defaults.
    if ($uid == 0) {
      $users[0] = $this
        ->getDefaultSettings();
    }
    else {
      $settings = $this->userData
        ->get('comment_notify', $uid);
      $users[$uid] = empty($settings) ? NULL : $settings;
    }
  }
  return $users[$uid];
}