You are here

function heartbeat_template_set_defaults in Heartbeat 7

Set the default values for a heartbeat_template.

The defaults are for a type defined through hook_heartbeat_template_info(). When populating a custom template $info should have the 'custom' key set to 1.

Parameters

$info: An object or array containing values to override the defaults.

Return value

A heartbeat template object.

File

./heartbeat.module, line 1146
Module file for heartbeat activity. Basic hook implementations and helper functions will be found here.

Code

function heartbeat_template_set_defaults($info = array()) {
  $template =& drupal_static(__FUNCTION__);
  if (!isset($template)) {
    $template = new HeartbeatMessageTemplate();
  }
  $new_template = clone $template;
  $info = (array) $info;
  foreach ($info as $key => $data) {
    $new_template->{$key} = $data;
  }
  if (empty($new_template->module)) {
    $new_template->module = $new_template->base == 'heartbeat_content' ? 'heartbeat' : '';
  }
  $new_template->orig_type = isset($info['template']) ? $info['template'] : '';
  return $new_template;
}