You are here

public function StreamTestController::stream in Heartbeat 8

Stream.

Return value

string Return Hello string.

File

src/Controller/StreamTestController.php, line 74

Class

StreamTestController
Class StreamTestController.

Namespace

Drupal\heartbeat\Controller

Code

public function stream() {
  $messages = array();
  $types = $this->heartbeatStreamService
    ->getTypesById(1);
  foreach ($types as $type) {
    if ($type != null) {
      $heartbeatType = $type
        ->getValue();
      $heartbeats = $this->heartbeatService
        ->loadByType($heartbeatType);
      foreach ($heartbeats as $heartbeat) {
        $messages[] = $heartbeat
          ->getMessage()
          ->getValue()[0]['value'];
      }
    }
  }
  return [
    '#theme' => 'heartbeat_stream',
    '#messages' => array_reverse($messages),
    '#attached' => array(
      'library' => 'heartbeat/heartbeat',
    ),
  ];
}