You are here

protected function HeartbeatAccess::finishMessages in Heartbeat 6.3

Same name and namespace in other branches
  1. 6.4 includes/heartbeataccess.inc \HeartbeatAccess::finishMessages()
1 call to HeartbeatAccess::finishMessages()
HeartbeatAccess::fetchMessages in includes/heartbeataccess.inc

File

includes/heartbeataccess.inc, line 98

Class

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

Code

protected function finishMessages(HeartbeatParser $heartbeat) {

  //do final things

  // Under certain conditions, the presence of a GROUP BY clause could
  // cause an ORDER BY clause to be ignored.

  //http://bugs.mysql.com/bug.php?id=32202
  if (count($heartbeat->raw_messages) > 0) {

    //$duplicates = module_invoke_all('heartbeat_messages_alter', $heartbeat->raw_messages, $this);
    $duplicates = array();
    $args = array(
      $heartbeat->raw_messages,
      $this,
    );
    $hook = 'heartbeat_messages_alter';
    $return = array();
    foreach (module_implements($hook) as $module) {
      $function = $module . '_' . $hook;
      $module_duplicates = call_user_func_array($function, $args);
      if (isset($module_duplicates) && is_array($module_duplicates)) {
        foreach ($module_duplicates as $key => $value) {
          $duplicates[$key] = $value;
        }
      }
    }
    $messages = $heartbeat->raw_messages;
    if (!empty($duplicates)) {
      $messages = array_diff_key($messages, $duplicates);
    }
    $heartbeat->raw_messages = $messages;
  }
  return $heartbeat;
}