public function HeartbeatStreamServices::createStreamForUidsByType in Heartbeat 8
File
- src/
HeartbeatStreamServices.php, line 202
Class
- HeartbeatStreamServices
- Class HeartbeatStreamServices.
Namespace
Drupal\heartbeatCode
public function createStreamForUidsByType($uids, $type) {
$stream = $this->entityTypeManager
->getStorage('heartbeat_stream')
->load(array_values($this
->loadStream($type))[0]);
if ($stream !== null) {
$types = array();
foreach ($stream
->getTypes() as $heartbeatType) {
$value = $heartbeatType
->getValue()['target_id'];
if ($value !== "0") {
$types[] = $value;
}
}
$beats = $this->entityTypeManager
->getStorage('heartbeat')
->loadMultiple($this->entityQuery
->get('heartbeat')
->condition('status', 1)
->condition('type', $types, 'IN')
->condition('uid', $uids, 'IN')
->sort('created', 'DESC')
->range(0, 25)
->execute());
if (count($beats) > 0) {
$this->lastId = call_user_func('end', array_keys($beats));
$this->configFactory
->getEditable('heartbeat_update_feed.settings')
->set('lastId', $this->lastId)
->set('update', false)
->set('timestamp', array_values($beats)[0]
->getRevisionCreationTime())
->save();
return $beats;
}
}
return null;
}