コード例 #1
0
ファイル: ContactImportHelper.php プロジェクト: antrampa/crm
 /**
  * There can be only one primary entity
  *
  * @param Contact $entity
  */
 public function updatePrimaryEntities(Contact $entity)
 {
     // update addresses
     $addresses = $entity->getAddresses();
     $primaryAddress = $this->getPrimaryEntity($addresses);
     if ($primaryAddress) {
         $entity->setPrimaryAddress($primaryAddress);
     } elseif ($addresses->count() > 0) {
         $entity->setPrimaryAddress($addresses->first());
     }
     // update emails
     $emails = $entity->getEmails();
     $primaryEmail = $this->getPrimaryEntity($emails);
     if ($primaryEmail) {
         $entity->setPrimaryEmail($primaryEmail);
     } elseif ($emails->count() > 0) {
         $entity->setPrimaryEmail($emails->first());
     }
     // update phones
     $phones = $entity->getPhones();
     $primaryPhone = $this->getPrimaryEntity($phones);
     if ($primaryPhone) {
         $entity->setPrimaryPhone($primaryPhone);
     } elseif ($phones->count() > 0) {
         $entity->setPrimaryPhone($phones->first());
     }
 }
コード例 #2
0
ファイル: SalesFunnelTest.php プロジェクト: antrampa/crm
 public function testGetOpportunityEmail()
 {
     $salesFunnel = new SalesFunnel();
     $email = new ContactEmail();
     $email->setEmail('*****@*****.**');
     $contact = new Contact();
     $contact->addEmail($email);
     $contact->setPrimaryEmail($email);
     $opportunity = new Opportunity();
     $opportunity->setContact($contact);
     $salesFunnel->setOpportunity($opportunity);
     $this->assertEquals('*****@*****.**', $salesFunnel->getEmail());
 }
コード例 #3
0
ファイル: ContactTest.php プロジェクト: antrampa/crm
 public function testGetEmail()
 {
     $contact = new Contact();
     $this->assertNull($contact->getEmail());
     $email = new ContactEmail('*****@*****.**');
     $contact->addEmail($email);
     $this->assertNull($contact->getEmail());
     $contact->setPrimaryEmail($email);
     $this->assertEquals('*****@*****.**', $contact->getEmail());
 }
コード例 #4
0
 /**
  * @param Contact $entity
  * @return Contact
  */
 protected function afterProcessEntity($entity)
 {
     // there can be only one primary entity
     $addresses = $entity->getAddresses();
     $primaryAddress = $this->getPrimaryEntity($addresses);
     if ($primaryAddress) {
         /** @var ContactAddress $primaryAddress */
         $entity->setPrimaryAddress($primaryAddress);
     } elseif ($addresses->count() > 0) {
         $entity->setPrimaryAddress($addresses->first());
     }
     $emails = $entity->getEmails();
     $primaryEmail = $this->getPrimaryEntity($emails);
     if ($primaryEmail) {
         /** @var ContactEmail $primaryEmail */
         $entity->setPrimaryEmail($primaryEmail);
     } elseif ($emails->count() > 0) {
         $entity->setPrimaryEmail($emails->first());
     }
     $phones = $entity->getPhones();
     $primaryPhone = $this->getPrimaryEntity($phones);
     if ($primaryPhone) {
         /** @var ContactPhone $primaryPhone */
         $entity->setPrimaryPhone($primaryPhone);
     } elseif ($phones->count() > 0) {
         $entity->setPrimaryPhone($phones->first());
     }
     return $entity;
 }
コード例 #5
0
ファイル: ContactTest.php プロジェクト: dairdr/crm
 public function testGetPrimaryEmail()
 {
     $contact = new Contact();
     $this->assertNull($contact->getPrimaryEmail());
     $email = new ContactEmail('*****@*****.**');
     $contact->addEmail($email);
     $this->assertNull($contact->getPrimaryEmail());
     $contact->setPrimaryEmail($email);
     $this->assertSame($email, $contact->getPrimaryEmail());
     $email2 = new ContactEmail('*****@*****.**');
     $contact->addEmail($email2);
     $contact->setPrimaryEmail($email2);
     $this->assertSame($email2, $contact->getPrimaryEmail());
     $this->assertFalse($email->isPrimary());
 }