Пример #1
0
 /**
  * @param ExternalIdentity $identity An object implementing ExternalIdentity
  */
 public function populateFromExternalIdentity(ExternalIdentity $identity)
 {
     if (!$this->getFirstname() && $identity->getFirstname()) {
         $this->setFirstname($identity->getFirstname());
     }
     if (!$this->getLastname() && $identity->getLastname()) {
         $this->setLastname($identity->getLastname());
     }
     // We're going to be adding email and phone records for this person.
     // We have to save the person record before we can do the foreign keys.
     if (!$this->getId()) {
         $this->save();
     }
     $list = $this->getEmails();
     if (!count($list) && $identity->getEmail()) {
         $email = new Email();
         $email->setPerson($this);
         $email->setEmail($identity->getEmail());
         $email->save();
     }
     $list = $this->getPhones();
     if (!count($list) && $identity->getPhone()) {
         $phone = new Phone();
         $phone->setPerson($this);
         $phone->setNumber($identity->getPhone());
         $phone->save();
     }
     $list = $this->getAddresses();
     if (!count($list) && $identity->getAddress()) {
         $address = new Address();
         $address->setPerson($this);
         $address->setAddress($identity->getAddress());
         $address->setCity($identity->getCity());
         $address->setState($identity->getState());
         $address->setZip($identity->setZip());
         $address->save();
     }
 }
 /**
  * @param ExternalIdentity $identity An object implementing ExternalIdentity
  */
 public function populateFromExternalIdentity(ExternalIdentity $identity)
 {
     if (!$this->getFirstname() && $identity->getFirstname()) {
         $this->setFirstname($identity->getFirstname());
     }
     if (!$this->getLastname() && $identity->getLastname()) {
         $this->setLastname($identity->getLastname());
     }
     if (!$this->getEmail() && $identity->getEmail()) {
         $this->setEmail($identity->getEmail());
     }
 }