You are here

class HeartbeatMessagePool in Heartbeat 7

Class to keep HeartbeatActivity messages in a pool so plugins and such can get the message instead of reloading them.

Hierarchy

Expanded class hierarchy of HeartbeatMessagePool

File

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

View source
class HeartbeatMessagePool {
  private static $instance = NULL;
  private $activity = array();

  /**
   * Constructor.
   */
  private function __construct() {
  }

  /**
   * getInstance().
   */
  public static function getInstance() {
    if (!isset(self::$instance)) {
      self::$instance = new HeartbeatMessagePool();
    }
    return self::$instance;
  }

  /**
   * getMessage().
   */
  public function getMessage($uaid) {
    if (!isset($this->activity[$uaid])) {
      $activity = _heartbeat_activity_load($uaid);
      if (!empty($activity)) {
        $this
          ->addMessage($activity);
        return $this->activity[$uaid];
      }
      else {
        return NULL;
      }
    }
    else {
      return $this->activity[$uaid];
    }
  }

  /**
   * addMessage().
   */
  public function addMessage($heartbeatActivity) {
    if (isset($heartbeatActivity)) {
      if (!isset($this->activity[$heartbeatActivity->uaid])) {
        $this->activity[$heartbeatActivity->uaid] = $heartbeatActivity;
      }
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
HeartbeatMessagePool::$activity private property
HeartbeatMessagePool::$instance private static property
HeartbeatMessagePool::addMessage public function addMessage().
HeartbeatMessagePool::getInstance public static function getInstance().
HeartbeatMessagePool::getMessage public function getMessage().
HeartbeatMessagePool::__construct private function Constructor.