You are here

public function HeartbeatStreamServices::updateStreamForUidsByType in Heartbeat 8

File

src/HeartbeatStreamServices.php, line 324

Class

HeartbeatStreamServices
Class HeartbeatStreamServices.

Namespace

Drupal\heartbeat

Code

public function updateStreamForUidsByType($uids, $type) {
  $currentUid = \Drupal::currentUser()
    ->id();
  $stream = $this->entityTypeManager
    ->getStorage('heartbeat_stream')
    ->load(array_values($this
    ->loadStream($type))[0]);
  $uids[] = $currentUid;
  return $this->entityTypeManager
    ->getStorage('heartbeat')
    ->loadMultiple($this->entityQuery
    ->get('heartbeat')
    ->condition('status', 1)
    ->condition('revision_created', $this->latestTimestamp, '>')
    ->condition('type', array_column($stream
    ->getTypes(), 'target_id'), 'IN')
    ->condition('uid', $uids, 'IN')
    ->sort('created', 'DESC')
    ->execute());
}