You are here

public function HeartbeatStream::render in Heartbeat 7

Render().

Function to create a renderable build array.

File

includes/heartbeatstream.inc, line 926
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 render() {
  $build = array();
  if ($this
    ->hasAccess()) {
    $path = drupal_get_path('module', 'heartbeat');
    $build = array(
      '#type' => 'markup',
      'messages' => array(),
    );
    $weight = 0;

    // Get the messages.
    foreach (array_keys($this->messages) as $key) {
      $build['messages'][$key] = heartbeat_activity_view($this->messages[$key], $this->view_mode);
      $build['messages'][$key]['#weight'] = $weight;
      $weight++;
    }
    $build['messages']['#sorted'] = TRUE;
    $build['pager'] = array(
      '#stream' => $this,
      '#theme' => 'activity_pager',
      '#weight' => 5,
    );
    if ($this
      ->needsModal()) {

      // Add CTools modal requirements.
      heartbeat_ctools_modal_prepare();
    }

    // Add the javascript and css files.
    drupal_add_js($path . '/js/heartbeat.js');
    if (variable_get('heartbeat_include_default_style', 1)) {
      drupal_add_css($path . '/css/heartbeat.css');
    }

    // Dirty hack to fix polled streams when no js/css can be included on custom ajax command.
    drupal_add_css($path . '/layouts/heartbeat_2col/heartbeat_2col.css');
  }
  return $build;
}