Example #1
0
 /**
  * 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;
     }
 }