示例#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;
 }
示例#2
0
 /**
  * Removes a customer.
  *
  * @param Model_Core_Customer $customer
  * The customer to remove.
  *
  * @return void
  */
 public function removeCustomer($customer)
 {
     $identifier = $customer->getIdentifier(Model_Core_Customer::IDENTIFIER);
     $where = $this->quoteInto('id = ?', $identifier);
     $this->delete($where);
 }
示例#3
0
 /**
  * Identifies if this customer is the same as the customer passed in.
  *
  * This method will identify a customer as equal to another customer if the
  * datas are the same.
  *
  * @param Model_Core_Customer $otherCustomer
  * The customer to compare this customer against.
  *
  * @return boolean
  * Returns true if the customers are equal, false otherwise.
  *
  * @todo
  * This method is incomplete.
  */
 public function equals($otherCustomer)
 {
     if ($this->_id != $otherCustomer->getIdentifier(self::IDENTIFIER)) {
         return false;
     }
     if ($this->_legacyId != $otherCustomer->getIdentifier(self::LEGACY_IDENTIFIER)) {
         return false;
     }
     if (strcasecmp($this->_title, $otherCustomer->getTitle()) != 0) {
         return false;
     }
     if (strcasecmp($this->_title, $otherCustomer->getFirstName()) != 0) {
         return false;
     }
     if (strcasecmp($this->_lastName, $otherCustomer->getLastname()) != 0) {
         return false;
     }
     if (strcasecmp($this->_addressLine1, $otherCustomer->getAddressLine(self::ADDRESSLINE1)) != 0) {
         return false;
     }
     if (strcasecmp($this->_addressLine2, $otherCustomer->getAddressLine(self::ADDRESSLINE2)) != 0) {
         return false;
     }
     if (strcasecmp($this->_addressLine3, $otherCustomer->getAddressLine(self::ADDRESSLINE3)) != 0) {
         return false;
     }
     if (strcasecmp($this->_postCode, $otherCustomer->getPostCode()) != 0) {
         return false;
     }
     if (strcasecmp($this->_country, $otherCustomer->getCountry()) != 0) {
         return false;
     }
     if ($this->_isForeignAddress != $otherCustomer->getIsForeignAddress()) {
         return false;
     }
     if ($this->_telephone1 != $otherCustomer->getTelephone(self::TELEPHONE1)) {
         return false;
     }
     if ($this->_telephone2 != $otherCustomer->getTelephone(self::TELEPHONE2)) {
         return false;
     }
     if ($this->_fax != $otherCustomer->getFax()) {
         return false;
     }
     if (strcasecmp($this->_emailAddress, $otherCustomer->getEmailAddress()) != 0) {
         return false;
     }
     if ($this->_password != $otherCustomer->getPassword()) {
         return false;
     }
     if ($this->_securityquestion != $otherCustomer->getSecurityQuestion()) {
         return false;
     }
     if ($this->_securityanswer != $otherCustomer->getSecurityAnswer()) {
         return false;
     }
     if (strcasecmp($this->_occupation, $otherCustomer->getOccupation()) != 0) {
         return false;
     }
     if ($this->_accountLoadComplete != $otherCustomer->getAccountLoadComplete()) {
         return false;
     }
     if ($this->_emailValidated != $otherCustomer->getEmailValidated()) {
         return false;
     }
     return true;
 }
示例#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;
 }