Exemplo n.º 1
0
 /**
  * Creates a new customer in the LegacyDataStore and returns an object representation of this.
  * 
  * @param string $emailAddress The customer's email address. No validation checking is performed on this,
  *          other than to check for a non-empty string.
  * @return Model_Core_Customer Returns a Customer object encapsulating the customer details.
  * @throws Zend_Exception Throws a Zend_Exception if parameters are missing.
  */
 public function createNewCustomer($emailAddress)
 {
     // Validate the data passed in.
     if (empty($emailAddress)) {
         throw new Zend_Exception('Required parameters missing');
     }
     // Save the customer into the LegacyDataStore.
     $passwordUtil = new Application_Core_Password();
     $password = $passwordUtil->generate();
     $identifier = $this->_customerModel->insertCustomer($emailAddress, $password, Model_Core_Customer::CUSTOMER);
     // Encapsulate the customer details in a Model_Core_Customer object and return
     $customer = new Model_Core_Customer();
     $customer->setIdentifier(Model_Core_Customer::IDENTIFIER, $identifier);
     $customer->setEmailAddress($emailAddress);
     $customer->setPassword($password);
     return $customer;
 }
Exemplo n.º 2
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;
     }
 }
 /**
  * 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;
 }
Exemplo n.º 4
0
 public function createCustomerFromLegacy($emailAddress, $legacyIdentifier)
 {
     //Validate the data passed in.
     if (empty($emailAddress) || empty($legacyIdentifier)) {
         throw new Zend_Exception('Required parameters missing');
     }
     //Save the customer into the DataStore and LegacyDataStore. To do this
     //first obtain the email address, password, customer type (tenant, landlord,
     //agent) and an unused legacy identifier (customerRefno).
     $passwordUtil = new Application_Core_Password();
     $password = $passwordUtil->generate();
     //And create:
     $identifier = $this->_customerModel->insertCustomer($emailAddress, $password, Model_Core_Customer::CUSTOMER);
     //Next link the LegacyDataStore and the DataStore.
     $customerMap = new Datasource_Core_CustomerMaps();
     $customerMap->insertMap($legacyIdentifier, $identifier);
     //Finally, encapsulate the customer details in a Model_Insurance_Common_Customer_DomainObjects_Customer
     //object and return.
     $customer = new Model_Core_Customer();
     $customer->setIdentifier(Model_Core_Customer::IDENTIFIER, $identifier);
     $customer->setIdentifier(Model_Core_Customer::LEGACY_IDENTIFIER, $legacyIdentifier);
     $customer->setEmailAddress($emailAddress);
     $customer->setPassword($password);
     return $customer;
 }