You are here

public function RedhenEngagement::save in RedHen CRM 7

Override parent to update a contacts engagement score.

Throws

Exception

Overrides Entity::save

File

modules/redhen_engagement/lib/redhen_engagement.entity.inc, line 57
RedhenEngagement entity classes

Class

RedhenEngagement
The class used for note entities.

Code

public function save() {
  $transaction = db_transaction();
  $ret = entity_get_controller($this->entityType)
    ->save($this, $transaction);
  if ($ret) {
    try {
      $contact = redhen_contact_load($this->contact_id);
      $contact->engagement_score = redhen_engagement_contact_score($contact);
      $contact
        ->save();
    } catch (Exception $e) {
      $transaction
        ->rollback();
      watchdog_exception($this->entityType, $e);
      throw $e;
    }
  }
  return $ret;
}