Exemplo n.º 1
0
 public function testRemoveAccount()
 {
     $account = new Account();
     $account->setId(1);
     $contact = new Contact();
     $contact->setId(2);
     $contact->addAccount($account);
     $this->assertCount(1, $contact->getAccounts()->toArray());
     $contact->removeAccount($account);
     $this->assertEmpty($contact->getAccounts()->toArray());
 }
Exemplo n.º 2
0
 /**
  * Remove contacts from account
  *
  * @param Contact $contact
  * @param Account[] $accounts
  */
 protected function removeAccounts(Contact $contact, array $accounts)
 {
     foreach ($accounts as $account) {
         $contact->removeAccount($account);
     }
 }
Exemplo n.º 3
0
 /**
  * @param Contact $entity
  */
 protected function processMultipleRelations(Contact $entity)
 {
     // update groups
     foreach ($entity->getGroups() as $group) {
         $entity->removeGroup($group);
         if ($group = $this->findExistingEntity($group)) {
             $entity->addGroup($group);
         }
     }
     // clear accounts
     foreach ($entity->getAccounts() as $account) {
         $entity->removeAccount($account);
     }
     // update addresses
     /** @var ContactAddress $contactAddress */
     foreach ($entity->getAddresses() as $contactAddress) {
         // update address types
         foreach ($contactAddress->getTypes() as $addressType) {
             $contactAddress->removeType($addressType);
             $existingAddressType = $this->findExistingEntity($addressType);
             if ($existingAddressType) {
                 $contactAddress->addType($existingAddressType);
             }
         }
     }
 }