You are here

public function StreamTestController::friendstream in Heartbeat 8

Stream.

Return value

string Return Hello string.

File

src/Controller/StreamTestController.php, line 104

Class

StreamTestController
Class StreamTestController.

Namespace

Drupal\heartbeat\Controller

Code

public function friendstream() {
  $messages = array();
  $types = $this->heartbeatStreamService
    ->getTypesById(2);
  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',
    ),
  ];
}