Beispiel #1
0
 public function send()
 {
     $this->assertTransport();
     $marketingList = $this->emailCampaign->getMarketingList();
     /** @var EntityManager $manager */
     $manager = $this->registry->getManager();
     foreach ($this->getIterator() as $entity) {
         $to = $this->contactInformationFieldsProvider->getQueryContactInformationFields($marketingList->getSegment(), $entity, ContactInformationFieldsProvider::CONTACT_INFORMATION_SCOPE_EMAIL);
         try {
             $manager->beginTransaction();
             // Do actual send
             $this->transport->send($this->emailCampaign, $entity, [$this->getSenderEmail() => $this->getSenderName()], $to);
             // Mark marketing list item as contacted
             $marketingListItem = $this->marketingListItemConnector->contact($marketingList, $entity->getId());
             // Record email campaign contact statistic
             $statisticsRecord = new EmailCampaignStatistics();
             $statisticsRecord->setEmailCampaign($this->emailCampaign)->setMarketingListItem($marketingListItem);
             $manager->persist($statisticsRecord);
             $manager->flush();
             $manager->commit();
         } catch (\Exception $e) {
             $manager->rollback();
             if ($this->logger) {
                 $this->logger->error(sprintf('Email sending to "%s" failed.', implode(', ', $to)), array('exception' => $e));
             }
         }
     }
     $this->emailCampaign->setSent(true);
     $manager->persist($this->emailCampaign);
     $manager->flush();
 }
Beispiel #2
0
 public function send()
 {
     if (!$this->assertTransport()) {
         return;
     }
     $marketingList = $this->emailCampaign->getMarketingList();
     if (is_null($marketingList)) {
         return;
     }
     $iterator = $this->getIterator();
     if (is_null($iterator)) {
         return;
     }
     /** @var EntityManager $manager */
     $manager = $this->registry->getManager();
     $emailFields = $this->contactInformationFieldsProvider->getMarketingListTypedFields($marketingList, ContactInformationFieldsProvider::CONTACT_INFORMATION_SCOPE_EMAIL);
     foreach ($iterator as $entity) {
         $to = $this->contactInformationFieldsProvider->getTypedFieldsValues($emailFields, $entity);
         $to = array_unique($to);
         try {
             $manager->beginTransaction();
             // Do actual send
             $this->transport->send($this->emailCampaign, $entity, [$this->getSenderEmail() => $this->getSenderName()], $to);
             $statisticsRecord = $this->statisticsConnector->getStatisticsRecord($this->emailCampaign, $entity);
             // Mark marketing list item as contacted
             $statisticsRecord->getMarketingListItem()->contact();
             $manager->flush($statisticsRecord);
             $manager->commit();
         } catch (\Exception $e) {
             $manager->rollback();
             if ($this->logger) {
                 $this->logger->error(sprintf('Email sending to "%s" failed.', implode(', ', $to)), ['exception' => $e]);
             }
         }
     }
     $this->emailCampaign->setSent(true);
     $manager->persist($this->emailCampaign);
     $manager->flush();
 }
 /**
  * @param TransportInterface $selectedTransport
  * @param FormInterface $form
  */
 protected function addTransportSettingsForm(TransportInterface $selectedTransport, FormInterface $form)
 {
     if ($selectedTransport) {
         $transportSettingsFormType = $selectedTransport->getSettingsFormType();
         if ($transportSettingsFormType) {
             $form->add('transportSettings', $transportSettingsFormType, ['required' => true]);
         } elseif ($form->has('transportSettings')) {
             $form->remove('transportSettings');
         }
     }
 }
 /**
  * @param TransportInterface $transport
  * @return bool
  */
 protected function isVisibleInForm($transport)
 {
     return !$transport instanceof VisibilityTransportInterface || $transport->isVisibleInForm();
 }
Beispiel #5
0
 /**
  * @param TransportInterface $transport
  */
 public function addTransport(TransportInterface $transport)
 {
     $this->transports[$transport->getName()] = $transport;
 }