/** * Updates an existing ReferenceSubject. * * @param Model_Referencing_ReferenceSubject $referenceSubject * The ReferenceSubject to update in the datasource. * * @return void */ public function updateReferenceSubject($referenceSubject) { if (empty($referenceSubject)) { return; } //Update linked name details, if given. if (empty($referenceSubject->name)) { $nameId = null; } else { //Obtain the $nameId for storage in this datasource. $nameId = $referenceSubject->name->id; //Update linked type. $namesDatasource = new Datasource_Core_Names(); $namesDatasource->updateName($referenceSubject->name); } //Update linked contact details, if given. if (empty($referenceSubject->contactDetails)) { $contactId = null; } else { //Obtain the $contactId for storage in this datasource. $contactId = $referenceSubject->contactDetails->id; //Update linked type. $contactDatasource = new Datasource_Core_ContactDetails(); $contactDatasource->updateContactDetails($referenceSubject->contactDetails); } //Translate the 'hasAdverseCredit' if (empty($referenceSubject->hasAdverseCredit)) { $hasAdverseCredit = 0; } else { if ($referenceSubject->hasAdverseCredit) { $hasAdverseCredit = 1; } else { $hasAdverseCredit = 0; } } //Translate 'isForeignNational' if (empty($referenceSubject->isForeignNational)) { $isForeignNational = 0; } else { if ($referenceSubject->isForeignNational) { $isForeignNational = 1; } else { $isForeignNational = 0; } } //Update... $data = array('name_id' => $nameId, 'contact_id' => $contactId, 'dob' => empty($referenceSubject->dob) ? null : $referenceSubject->dob->toString(Zend_Date::ISO_8601), 'type_id' => $referenceSubject->type, 'has_adverse_credit' => $hasAdverseCredit, 'rent_share' => empty($referenceSubject->shareOfRent) ? null : $referenceSubject->shareOfRent->getValue(), 'is_foreign_national' => $isForeignNational); $where = $this->quoteInto('reference_id = ?', $referenceSubject->referenceId); $this->update($data, $where); }
/** * Updates an existing OccupationalReferee in the datasource. * * @param Model_Referencing_OccupationalReferee * The OccupationalReferee to update. * * @return void */ public function updateReferee($occupationalReferee) { if (empty($occupationalReferee)) { return; } //Update linked name details, if given. if (empty($occupationalReferee->name)) { $nameId = null; } else { //Obtain the $nameId for storage in this datasource. $nameId = $occupationalReferee->name->id; //Update linked type. $namesDatasource = new Datasource_Core_Names(); $namesDatasource->updateName($occupationalReferee->name); } //Update linked contact details, if given. if (empty($occupationalReferee->contactDetails)) { $contactId = null; } else { //Obtain the $contactId for storage in this datasource. $contactId = $occupationalReferee->contactDetails->id; //Update linked type. $contactDatasource = new Datasource_Core_ContactDetails(); $contactDatasource->updateContactDetails($occupationalReferee->contactDetails); } //Update linked address details, if given. if (empty($occupationalReferee->address)) { $addressId = null; } else { //Obtain the $addressId for storage in this datasource. $addressId = $occupationalReferee->address->id; //Update linked type. $addressDatasource = new Datasource_Core_Addresses(); $addressDatasource->updateAddress($occupationalReferee->address); } //Update... $data = array('name_id' => empty($occupationalReferee->name) ? null : $occupationalReferee->name->id, 'contact_id' => empty($occupationalReferee->contactDetails) ? null : $occupationalReferee->contactDetails->id, 'address_id' => empty($occupationalReferee->address) ? null : $occupationalReferee->address->id, 'referee_position' => $occupationalReferee->position, 'organisation_name' => $occupationalReferee->organisationName); $where = $this->quoteInto('occupation_id = ?', $occupationalReferee->occupationId); $this->update($data, $where); }