コード例 #1
0
 /**
  * @param \Generated\Shared\Transfer\NewsletterSubscriberTransfer $subscriberTransfer
  *
  * @return \Orm\Zed\Newsletter\Persistence\SpyNewsletterSubscriber|null
  */
 protected function findSubscriberEntity(NewsletterSubscriberTransfer $subscriberTransfer)
 {
     $subscriberQuery = $this->queryContainer->querySubscriber();
     $idNewsletterSubscriber = $subscriberTransfer->getIdNewsletterSubscriber();
     if ($idNewsletterSubscriber !== null) {
         return $subscriberQuery->findOneByIdNewsletterSubscriber($idNewsletterSubscriber);
     }
     $email = $subscriberTransfer->getEmail();
     if ($email !== null) {
         return $subscriberQuery->findOneByEmail($email);
     }
     return null;
 }
コード例 #2
0
 /**
  * @param \Generated\Shared\Transfer\NewsletterSubscriberTransfer $newsletterSubscriber
  *
  * @return \Generated\Shared\Transfer\NewsletterSubscriptionApprovalResultTransfer
  */
 public function approveSubscriberByKey(NewsletterSubscriberTransfer $newsletterSubscriber)
 {
     $result = new NewsletterSubscriptionApprovalResultTransfer();
     $subscriberEntity = $this->queryContainer->querySubscriber()->findOneBySubscriberKey($newsletterSubscriber->getSubscriberKey());
     if ($subscriberEntity === null) {
         $result->setIsSuccess(false);
         $result->setErrorMessage(Messages::INVALID_SUBSCRIBER_KEY);
         return $result;
     }
     $subscriberEntity->setIsConfirmed(true);
     $subscriberEntity->save();
     $result->setIsSuccess(true);
     return $result;
 }
コード例 #3
0
 /**
  * @param \Generated\Shared\Transfer\NewsletterSubscriberTransfer $newsletterSubscriber
  *
  * @return bool
  */
 public function send(NewsletterSubscriberTransfer $newsletterSubscriber)
 {
     $config = $this->getFactory()->getConfig();
     $mailTransfer = $this->createMailTransfer();
     $mailTransfer->setTemplateName($config->getDoubleOptInConfirmationTemplateName());
     $this->addMailRecipient($mailTransfer, $newsletterSubscriber->getEmail());
     $this->setMailTransferFrom($mailTransfer, $config);
     $this->setMailTransferSubject($mailTransfer, $config);
     $globalMergeVars = $this->getMailGlobalMergeVars($config->getDoubleOptInApproveTokenUrl($newsletterSubscriber->getSubscriberKey()));
     $this->setMailMergeData($mailTransfer, $globalMergeVars);
     $mailFacade = $this->getFactory()->getMailFacade();
     $responses = $mailFacade->sendMail($mailTransfer);
     $result = $mailFacade->isMailSent($responses);
     return $result;
 }
コード例 #4
0
 /**
  * @param \Generated\Shared\Transfer\NewsletterSubscriberTransfer $newsletterSubscriber
  * @param \Generated\Shared\Transfer\NewsletterTypeTransfer $newsletterType
  *
  * @return \Orm\Zed\Newsletter\Persistence\SpyNewsletterSubscription|null
  */
 protected function getSubscription(NewsletterSubscriberTransfer $newsletterSubscriber, NewsletterTypeTransfer $newsletterType)
 {
     if ($newsletterSubscriber->getSubscriberKey() !== null) {
         $subscriptionEntity = $this->queryContainer->querySubscriptionBySubscriberKeyAndNewsletterTypeName($newsletterSubscriber->getSubscriberKey(), $newsletterType->getName())->findOne();
         return $subscriptionEntity;
     }
     if ($newsletterSubscriber->getFkCustomer() !== null) {
         $subscriptionEntity = $this->queryContainer->querySubscriptionByIdCustomerAndNewsletterTypeName($newsletterSubscriber->getFkCustomer(), $newsletterType->getName())->findOne();
         return $subscriptionEntity;
     }
     return null;
 }
コード例 #5
0
 /**
  * @return \Generated\Shared\Transfer\NewsletterSubscriberTransfer
  */
 protected function createSubscriber()
 {
     $subscriber = new NewsletterSubscriberTransfer();
     $subscriber->setEmail('*****@*****.**');
     $subscriber->setSubscriberKey('*****@*****.**');
     return $subscriber;
 }
コード例 #6
0
 /**
  * @param \Generated\Shared\Transfer\NewsletterSubscriberTransfer $newsletterSubscriberTransfer
  *
  * @throws \Spryker\Zed\Newsletter\Business\Exception\MissingNewsletterSubscriberEmailException
  *
  * @return \Generated\Shared\Transfer\NewsletterSubscriberTransfer
  */
 protected function getNewsletterSubscriber(NewsletterSubscriberTransfer $newsletterSubscriberTransfer)
 {
     $email = $newsletterSubscriberTransfer->getEmail();
     if ($newsletterSubscriberTransfer->getEmail() === null) {
         throw new MissingNewsletterSubscriberEmailException('Missing newsletter subscriber email.');
     }
     $loadedNewsletterSubscriberTransfer = $this->subscriberManager->loadSubscriberByEmail($email);
     $this->subscriberExists = true;
     if ($loadedNewsletterSubscriberTransfer === null) {
         $loadedNewsletterSubscriberTransfer = $this->subscriberManager->createSubscriberFromTransfer($newsletterSubscriberTransfer);
         $this->subscriberExists = false;
     }
     return $loadedNewsletterSubscriberTransfer;
 }
コード例 #7
0
 /**
  * @param \Orm\Zed\Newsletter\Persistence\SpyNewsletterSubscriber $subscriberEntity
  *
  * @return \Generated\Shared\Transfer\NewsletterSubscriberTransfer
  */
 protected function convertSubscriberEntityToTransfer(SpyNewsletterSubscriber $subscriberEntity)
 {
     $subscriberTransfer = new NewsletterSubscriberTransfer();
     $subscriberTransfer->fromArray($subscriberEntity->toArray(), true);
     return $subscriberTransfer;
 }