/** * {@inheritdoc} */ public function load(ObjectManager $manager) { $contact = $this->getReference('Contact_' . LoadContactEntitiesData::FIRST_ENTITY_NAME); foreach ($this->contactEmailData as $contactEmailData) { $contactEmail = new ContactEmail(); $contactEmail->setPrimary($contactEmailData['primary']); $contactEmail->setOwner($contact); $contactEmail->setEmail($contactEmailData['email']); $this->setReference('ContactEmail_Several_' . $contactEmailData['email'], $contactEmail); $manager->persist($contactEmail); } $contact2 = $this->getReference('Contact_' . LoadContactEntitiesData::SECOND_ENTITY_NAME); $contactEmail = new ContactEmail(); $contactEmail->setPrimary($this->contactEmailData[0]['primary']); $contactEmail->setOwner($contact2); $contactEmail->setEmail($this->contactEmailData[0]['email']); $this->setReference('ContactEmail_Single_' . $this->contactEmailData[0]['email'], $contactEmail); $manager->persist($contactEmail); $manager->flush(); }
/** * @param ContactEmail $entity * @param Contact $contact */ protected function onSuccess(ContactEmail $entity, Contact $contact) { $entity->setOwner($contact); $this->manager->persist($entity); $this->manager->flush(); }
public function dataTest() { $testContact = new ExtendContact(); $testContactAddress = new ContactAddress(); $testContactEmail = new ContactEmail(); $testContactPhone = new ContactPhone(); $testContactAddress->setOwner($testContact); $testContactEmail->setOwner($testContact); $testContactPhone->setOwner($testContact); $testMagentoCustomer = new ExtendCustomer(); $channel = new Channel(); $channel->getSynchronizationSettingsReference()->offsetSet('isTwoWaySyncEnabled', true); $channel->setName('test'); $channel->setEnabled(true); $testMagentoCustomer->setChannel($channel); return ['Updated contact' => [$testContact, $testMagentoCustomer, $channel, [], [$testContact], [], true, true, true, true, true], 'Inserted contact' => [$testContact, $testMagentoCustomer, $channel, [$testContact], [], [], true, false, false, true, false], 'Deleted contact' => [$testContact, $testMagentoCustomer, $channel, [], [], [$testContact], true, true, true, false, true], 'Updated contact with testContactAddress' => [$testContact, $testMagentoCustomer, $channel, [], [$testContact, $testContactAddress], [], true, true, true, true, true], 'Test process Contact Address' => [$testContact, $testMagentoCustomer, $channel, [], [$testContactAddress], [], true, true, true, false, true], 'Test deleted Contact Address' => [$testContact, $testMagentoCustomer, $channel, [], [], [$testContactAddress], true, true, true, false, true]]; }