public function RedhenContactEntityController::save in RedHen CRM 7
Saves a contact.
Parameters
RedhenContact $contact: The full contact object to save.
Return value
RedhenContact The saved contact object.
Overrides EntityAPIController::save
File
- modules/
redhen_contact/ lib/ redhen_contact.controller.inc, line 24 - The controller for the contact entity containing the CRUD operations.
Class
- RedhenContactEntityController
- The controller class for contacts.
Code
public function save($contact, DatabaseTransaction $transaction = NULL) {
$transaction = isset($transaction) ? $transaction : db_transaction();
try {
$contact->updated = REQUEST_TIME;
// New contact, set created prop.
if (isset($contact->is_new) && $contact->is_new && !isset($contact->created)) {
$contact->created = REQUEST_TIME;
}
else {
if (!isset($contact->is_new_revision)) {
$contact->is_new_revision = TRUE;
}
if (!isset($contact->default_revision)) {
$contact->default_revision = TRUE;
}
}
parent::save($contact, $transaction);
// Set the contact user.
if ($contact->uid) {
$this
->setUser($contact, $transaction);
}
return $contact;
} catch (Exception $e) {
$transaction
->rollback();
watchdog_exception($this->entityType, $e);
throw $e;
}
}