/** * Writes the Reference object to the legacy datasources. * * @param Model_Referencing_Reference $reference * The reference to write to the Munt. * * @return void */ protected function _pushToMunt(Model_Referencing_Reference $reference) { // Check the legacy customer id is set if ($reference->customer->legacyCustomerId == null && $reference->customer->customerType == Model_Referencing_CustomerTypes::LANDLORD) { // Create a new legacy customer for the private landlord $customerManager = new Manager_Core_Customer(); $customer = $customerManager->getCustomer(Model_Core_Customer::IDENTIFIER, $reference->customer->customerId); $legacyCustomer = $customerManager->createNewCustomer($customer->getEmailAddress(), Model_Core_Customer::CUSTOMER, true); $legacyCustomer->setFirstName($customer->getFirstName()); $legacyCustomer->setLastName($customer->getLastName()); $legacyCustomer->setAddressLine(Model_Core_Customer::ADDRESSLINE1, $customer->getAddressLine(Model_Core_Customer::ADDRESSLINE1)); $legacyCustomer->setAddressLine(Model_Core_Customer::ADDRESSLINE2, $customer->getAddressLine(Model_Core_Customer::ADDRESSLINE2)); $legacyCustomer->setAddressLine(Model_Core_Customer::ADDRESSLINE3, $customer->getAddressLine(Model_Core_Customer::ADDRESSLINE3)); $legacyCustomer->setTelephone(Model_Core_Customer::TELEPHONE1, $customer->getTelephone(Model_Core_Customer::TELEPHONE1)); $legacyCustomer->setTelephone(Model_Core_Customer::TELEPHONE2, $customer->getTelephone(Model_Core_Customer::TELEPHONE2)); $legacyCustomer->setPassword($customer->getPassword()); $customerManager->updateCustomer($legacyCustomer); // Drop the legacy customer refno into the reference customer map object $reference->customer->legacyCustomerId = $legacyCustomer->getIdentifier(Model_Core_Customer::LEGACY_IDENTIFIER); } $muntManager = new Manager_ReferencingLegacy_Munt(); $muntManager->updateReference($reference); }