You are here

function UserNotificationSettings::saveSettings in Comment Notify 8

Sets the notification preferences for a specific user.

Parameters

int $uid: The User ID.

int $entity_notification: The entity notification value.

int $comment_notification: The comment notification value.

File

src/UserNotificationSettings.php, line 115

Class

UserNotificationSettings
Defines the Comment notify user settings.

Namespace

Drupal\comment_notify

Code

function saveSettings($uid, $entity_notification = NULL, $comment_notification = NULL) {
  if (!$uid) {
    throw new \Exception('Cannot set user preference, uid missing');
  }
  if (!is_null($entity_notification)) {
    $this->userData
      ->set('comment_notify', $uid, 'entity_notify', $entity_notification);
  }
  if (!is_null($comment_notification)) {
    $this->userData
      ->set('comment_notify', $uid, 'comment_notify', $comment_notification);
  }
}