You are here

public function PushNotificationsTokenQuery::getTokensByUid in Push Notifications 8

Get the push notification tokens by user ID.

Parameters

array $uids: User IDs.

Return value

array|null

File

src/PushNotificationsTokenQuery.php, line 55
Contains Drupal\push_notifications\PushNotificationsTokenQuery.

Class

PushNotificationsTokenQuery

Namespace

Drupal\push_notifications

Code

public function getTokensByUid($uids) {
  if (!is_array($uids)) {
    return NULL;
  }
  $push_notifications_token_storage = $this->entityManager
    ->getStorage('push_notifications_token');
  $push_notifications_token = $push_notifications_token_storage
    ->loadByProperties(array(
    'uid' => $uids,
  ));
  $tokens = array();
  foreach ($push_notifications_token as $pid => $push_notification_token) {
    array_push($tokens, $push_notification_token
      ->getToken());
  }
  return $tokens;
}