/** * Assign MergeVar values to properties of Member * * @param Member $member */ protected function assignMergeVarValues(Member $member) { $subscribersList = $member->getSubscribersList(); if (!$subscribersList) { return; } $this->mergeVarProvider->assignMergeVarValues($member, $this->mergeVarProvider->getMergeVarFields($subscribersList)); }
/** * {@inheritdoc} */ public function load(ObjectManager $manager) { $organization = $manager->getRepository('OroOrganizationBundle:Organization')->getFirst(); foreach ($this->data as $data) { $entity = new Member(); $entity->setOwner($organization); $data['subscribersList'] = $this->getReference($data['subscribersList']); $data['channel'] = $this->getReference($data['channel']); $this->setEntityPropertyValues($entity, $data, ['reference']); $this->setReference($data['reference'], $entity); $manager->persist($entity); } $manager->flush(); }
/** * {@inheritdoc} */ public function assignMergeVarValues(Member $member, MergeVarFieldsInterface $fields) { $values = $member->getMergeVarValues(); $member->setEmail($this->getMergeVarValue($values, $fields->getEmail())); $member->setPhone($this->getMergeVarValue($values, $fields->getPhone())); $member->setFirstName($this->getMergeVarValue($values, $fields->getFirstName())); $member->setLastName($this->getMergeVarValue($values, $fields->getLastName())); }
/** * @param Member $member * @return MarketingListStateItemInterface[] */ protected function getMarketingListStateItems(Member $member) { $entities = []; if (!($subscribersList = $member->getSubscribersList())) { return $entities; } $marketingLists = $this->getMarketingListIterator($subscribersList); foreach ($marketingLists as $marketingList) { $marketingListEntities = $this->getMarketingListEntitiesByEmail($marketingList, $member->getEmail()); /** @var MarketingList $marketingListEntity */ foreach ($marketingListEntities as $marketingListEntity) { $entityId = $this->doctrineHelper->getSingleEntityIdentifier($marketingListEntity); $criteria = ['entityId' => $entityId, 'marketingList' => $marketingList->getId()]; if ($this->getMarketingListStateItem($criteria)) { continue; } /** @var MarketingListStateItemInterface $marketingListStateItem */ $marketingListStateItem = new $this->marketingListStateItemClassName(); $marketingListStateItem->setEntityId($entityId)->setMarketingList($marketingList); $entities[$marketingList->getEntity()][] = $marketingListStateItem; } } return $entities; }
public function testAssignMergeVarValuesWorksWithEmptyFields() { $mergeVarFields = $this->getMock('OroCRM\\Bundle\\MailChimpBundle\\Model\\MergeVar\\MergeVarFieldsInterface'); $mergeVarFields->expects($this->once())->method('getEmail')->will($this->returnValue(null)); $mergeVarFields->expects($this->once())->method('getPhone')->will($this->returnValue(null)); $mergeVarFields->expects($this->once())->method('getFirstName')->will($this->returnValue(null)); $mergeVarFields->expects($this->once())->method('getLastName')->will($this->returnValue(null)); $email = '*****@*****.**'; $phone = '333-555-7777'; $firstName = 'John'; $lastName = 'Doe'; $member = new Member(); $member->setMergeVarValues(['Email Address' => $email, 'Phone' => $phone, 'First Name' => $firstName, 'Last Name' => $lastName]); $this->provider->assignMergeVarValues($member, $mergeVarFields); $this->assertNull($member->getEmail()); $this->assertNull($member->getPhone()); $this->assertNull($member->getFirstName()); $this->assertNull($member->getLastName()); }
/** * @param Member $member * @param Channel $channel * @param Campaign $campaign * @return Member */ protected function findExistingMember(Member $member, Channel $channel, Campaign $campaign) { $searchCondition = ['channel' => $channel, 'subscribersList' => $campaign->getSubscribersList()]; if ($originId = $member->getOriginId()) { $searchCondition['originId'] = $originId; } else { $searchCondition['email'] = $member->getEmail(); } return $this->findEntityByIdentityValues(ClassUtils::getClass($member), $searchCondition); }
public function testPreUpdate() { $this->assertNull($this->target->getUpdatedAt()); $this->target->preUpdate(); $this->assertInstanceOf('\\DateTime', $this->target->getUpdatedAt()); }