/**
  * {@inheritdoc}
  */
 public function load(ObjectManager $manager)
 {
     $organization = $manager->getRepository('OroOrganizationBundle:Organization')->getFirst();
     foreach ($this->data as $data) {
         $entity = new Campaign();
         $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();
 }
 /**
  * @return array
  */
 protected function getArguments()
 {
     return ['cid' => $this->campaign->getOriginId(), 'opts' => ['start' => (int) $this->offset / $this->batchSize, 'limit' => $this->batchSize]];
 }
 /**
  * Creates iterator of member activities for campaign
  *
  * @param Campaign $campaign
  * @return \Iterator
  */
 protected function createResultIterator(Campaign $campaign)
 {
     $parameters = $this->parameters;
     $parameters['id'] = $campaign->getOriginId();
     return $this->createExportIterator(MailChimpClient::EXPORT_CAMPAIGN_SUBSCRIBER_ACTIVITY, $parameters);
 }
 /**
  * @param MemberActivity $memberActivity
  * @param Channel $channel
  * @param Campaign $campaign
  * @return Member|null
  */
 protected function findExistingMember(MemberActivity $memberActivity, Channel $channel, Campaign $campaign)
 {
     $searchCondition = ['channel' => $channel, 'subscribersList' => $campaign->getSubscribersList()];
     $member = $memberActivity->getMember();
     $email = $member ? $member->getEmail() : $memberActivity->getEmail();
     if ($member && ($originId = $member->getOriginId())) {
         $searchCondition['originId'] = $originId;
     } elseif ($email) {
         $searchCondition['email'] = $email;
     } else {
         return null;
     }
     return $this->findEntityByIdentityValues('OroCRM\\Bundle\\MailChimpBundle\\Entity\\Member', $searchCondition);
 }
 /**
  * @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);
 }
Пример #6
0
 public function testPreUpdate()
 {
     $this->assertNull($this->target->getUpdatedAt());
     $this->target->preUpdate();
     $this->assertInstanceOf('\\DateTime', $this->target->getUpdatedAt());
 }