You are here

function hds_preprocess_heartbeat_message_row in Heartbeat 6.4

Implementation of hook_preprocess_heartbeat_message_row().

File

modules/hds/hds.module, line 86
Heartbeat displays module.

Code

function hds_preprocess_heartbeat_message_row(&$vars) {

  // DS expects an array. Make sure that it contains the exact
  // fields DS expects. The __get/__set will end up in the
  // variables container of object HeartbeatActivity.
  // Here it is put back in the root of the hash to let DS play with it.
  // Another approach would be to wrap the object in another object with
  // a composition as vd does. I chose the magic setter manner since this
  // could be used by other modules.
  $message = (array) $vars['message'];
  $message += $message['variables'];

  // Break all the rendering if needed.
  if (!$vars['message']->render_by_ds) {
    $vars['template_files'][] = 'heartbeat-message-row';
    return;
  }

  // Add template suggestions only if the build mode is not excluded.
  $vars['template_files'][] = 'hds';
  $vars['template_files'][] = 'hds-' . $message['build_mode'];
  $vars['template_files'][] = 'hds-' . $message['build_mode'] . '-' . $message['message_id'];
  $vars['content'] = ds_render_content($vars['message'], 'hds', $message);
}