public function testGetGroupLabelsAsString() { $entity = new Contact(); $this->assertEquals('', $entity->getGroupLabelsAsString()); $entity->addGroup(new Group('Group One')); $this->assertEquals('Group One', $entity->getGroupLabelsAsString()); $entity->addGroup(new Group('Group Two')); $this->assertEquals('Group One, Group Two', $entity->getGroupLabelsAsString()); }
/** * @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); } } } }