/** * Retrieves the specified customer record, encapsulates the details in a * Customer object and returns this. * * @param $identifier * @return param $identifier * Identifies the customer record in the customers table. * * @return \param The customer details encapsulated in a Customer object. */ public function getCustomer($identifier) { //Retrieve the customer record. $select = $this->select(); $select->where('id = ?', $identifier); $customerRow = $this->fetchRow($select); if ($customerRow) { //Populate the details into a Customer object. $customer = new Model_Core_Customer(); $customer->setIdentifier(Model_Core_Customer::IDENTIFIER, $identifier); $customerMaps = new Datasource_Core_CustomerMaps(); $customerMap = $customerMaps->getMap(Model_Core_Customer::IDENTIFIER, $identifier); if ($customerMap) { $customer->setIdentifier(Model_Core_Customer::LEGACY_IDENTIFIER, $customerMap->getLegacyIdentifier()); } $customer->setTitle($customerRow->title); $customer->setFirstName($customerRow->first_name); $customer->setLastName($customerRow->last_name); $customer->setLandlordName($customerRow->landname); $customer->setAddressLine(Model_Core_Customer::ADDRESSLINE1, $customerRow->address1); $customer->setAddressLine(Model_Core_Customer::ADDRESSLINE2, $customerRow->address2); $customer->setAddressLine(Model_Core_Customer::ADDRESSLINE3, $customerRow->address3); $customer->setPostCode($customerRow->postcode); $customer->setCountry($customerRow->country); if ($customerRow->foreign_address == 0) { $customer->setIsForeignAddress(false); } else { $customer->setIsForeignAddress(true); } $customer->setTelephone(Model_Core_Customer::TELEPHONE1, $customerRow->telephone1); $customer->setTelephone(Model_Core_Customer::TELEPHONE2, $customerRow->telephone2); $customer->setEmailAddress($customerRow->email_address); $customer->setPassword($customerRow->password); $customer->setOccupation($customerRow->occupation); $customer->setEmailValidated($customerRow->email_validated == 1 ? true : false); $customer->setAccountLoadComplete($customerRow->account_load_complete == 1 ? true : false); $customerTypeName = array_search($customerRow->type_id, $this->_legacyTypeMap); if ($customerTypeName !== false) { $customer->typeID = $customerTypeName; } return $customer; } else { return null; } }
/** * Retrieves the specified customer record, encapsulates the details in a * Customer object and returns this. * * @param string $identifier * Identifies the customer record in the legacy customer table. * * @return Model_Core_Customer * The customer details encapsulated in a Customer object.#5 /home/benjamin.vickers/HomeLet-Framework/src/application/models/datasources/Core/LegacyCustomers.php(209): Zend_Db_Table_Abstract->fetchRow(Object(Zend_Db_Table_Select)) * * @throws Zend_Exception * Throws a Zend_Exception if the customer record cannot be found. */ public function getCustomer($identifier) { //Retrieve the customer record. $select = $this->select(); $select->where('refno = ?', $identifier); $customerRow = $this->fetchRow($select); if (empty($customerRow)) { throw new Zend_Exception('Customer not found.'); } //Populate the details into a Customer object. $customer = new Model_Core_Customer(); $customer->setIdentifier(Model_Core_Customer::LEGACY_IDENTIFIER, $identifier); $customerMaps = new Datasource_Core_CustomerMaps(); $customerMap = $customerMaps->getMap(Model_Core_Customer::LEGACY_IDENTIFIER, $identifier); if ($customerMap) { $customer->setIdentifier(Model_Core_Customer::IDENTIFIER, $customerMap->getIdentifier()); } $customer->setTitle($customerRow->title); $customer->setFirstName($customerRow->firstname); $customer->setLastName($customerRow->lastname); $customer->setAddressLine(Model_Core_Customer::ADDRESSLINE1, $customerRow->personaladdress1); $customer->setAddressLine(Model_Core_Customer::ADDRESSLINE2, $customerRow->personaladdress3); $customer->setAddressLine(Model_Core_Customer::ADDRESSLINE3, $customerRow->personaladdress5); $customer->setPostCode($customerRow->personalpostcode); $customer->setCountry($customerRow->country); if ($customerRow->isForeignAddress == 'no') { $customer->setIsForeignAddress(false); } else { $customer->setIsForeignAddress(true); } $customer->setTelephone(Model_Core_Customer::TELEPHONE1, $customerRow->phone1); $customer->setTelephone(Model_Core_Customer::TELEPHONE2, $customerRow->phone2); $customer->setFax($customerRow->fax); $customer->setEmailAddress($customerRow->email); $customer->setPassword($customerRow->password); $customer->setOccupation($customerRow->occupation); $customer->setDateOfBirthAt($customerRow->date_of_birth_at); $customer->typeID = 2; // Default to a tenant return $customer; }