You are here

public function HeartbeatStream::execute in Heartbeat 7

Function that reorganizes a query result of messages into a stream of heartbeat activity objects.

Return value

$messages array of messages

File

includes/heartbeatstream.inc, line 835
HeartbeatStream object is the object that takes stream configuration to create a stream of activity objects. It is the controlling organ at the pre-query, query and post-query phases.

Class

HeartbeatStream
Abstract class HeartbeatStream This base class has final template methods which are used by the derived concretes. The HeartbeatStream is a state object that is given to the HeartbeatStreamBuilder to set the access to the current request.

Code

public function execute() {

  // Fetch the messages from database for current Stream
  $result = $this
    ->result();
  if (!isset($result)) {
  }
  elseif (!empty($result)) {

    // Filter messages by permission.
    $this
      ->checkAccess($result);

    // Group the activity messages as configured
    $messages = $this
      ->parseMessages($result);

    // Give contributes modules the opportunity to load
    // additions for the heartbeat activity message object.
    $hook = 'heartbeat_load';
    foreach (module_implements($hook) as $module) {
      $function = $module . '_' . $hook;

      // $messages should be implemented by reference!!!
      $function($result, $this);
    }

    // Let other modules retheme or completely rebuild messages
    $hook = 'heartbeat_theme_alter';
    foreach (module_implements($hook) as $module) {
      $function = $module . '_' . $hook;
      $result = $function($messages, $this);
    }
    $this->messages = $messages;
  }
  return $this->messages;
}