You are here

public function HeartbeatStreamServices::loadAllStreams in Heartbeat 8

File

src/HeartbeatStreamServices.php, line 112

Class

HeartbeatStreamServices
Class HeartbeatStreamServices.

Namespace

Drupal\heartbeat

Code

public function loadAllStreams() {
  $types = null;
  foreach ($this
    ->getAllStreams() as $stream) {
    foreach ($stream
      ->getTypes() as $type) {
      $type = $type
        ->getValue();
      $type = key($type) === 'target_id' ? $type : $type
        ->getValue()[0];
      if (strlen($type['target_id']) > 1) {
        $types[] = $type;
      }
    }
  }
  $cleanTypes = array_column($types, 'target_id');
  return $this->entityTypeManager
    ->getStorage('heartbeat')
    ->loadMultiple($this->entityQuery
    ->get('heartbeat')
    ->condition('status', 1)
    ->condition('type', array_column($types, 'target_id'), 'IN')
    ->sort('created', 'DESC')
    ->range(0, 25)
    ->execute());
}