/** * @param Bronto_Api_Contact_Row $contact * @param bool $persistOnly * * @return Bronto_Api_Contact_Row */ public function saveContact(Bronto_Api_Contact_Row $contact, $persistOnly = false) { if ($persistOnly) { $contact->persist(); } else { try { if ($contact->id) { $this->writeDebug("Updating existing Contact: ({$contact->email})..."); } else { $this->writeDebug("Saving new Contact: ({$contact->email})..."); } $contact->save(false); } catch (Exception $e) { $this->writeError($e); } } $this->writeVerboseDebug('===== CONTACT SAVE =====', 'bronto_common_api.log'); $this->writeVerboseDebug(var_export($contact->getApi()->getLastRequest(), true), 'bronto_common_api.log'); $this->writeVerboseDebug(var_export($contact->getApi()->getLastResponse(), true), 'bronto_common_api.log'); return $contact; }
/** * @covers Bronto_Api_Contact_Row::save * @depends testDeleteContactAfterRead */ public function testSaveContactAfterDeleteCaughtException(Bronto_Api_Contact_Row $contact) { $contact->status = 'transactional'; try { $contact->save(); } catch (Bronto_Api_Row_Exception $e) { // } $this->assertEquals(1, count($contact->getData())); $this->assertTrue($contact->isReadOnly()); $this->assertFalse($contact->hasError(), 'Contact has error: ' . $contact->getErrorMessage()); $this->assertFalse($contact->isNew()); }
/** * @param Bronto_Api_Contact_Row $contact * @param bool $persistOnly * * @return Bronto_Api_Contact_Row */ public function saveContact(Bronto_Api_Contact_Row $contact, $persistOnly = false) { if ($persistOnly) { $contact->persist(); } else { try { if ($contact->id) { $this->writeDebug("Updating existing Contact: ({$contact->email})..."); } else { $this->writeDebug("Saving new Contact: ({$contact->email})..."); } $contact->save(false); } catch (Exception $e) { $this->writeError($e); } $this->_flushApiLogs($contact->getApi()); } return $contact; }