protected function createNewsletterLog($className, NewsletterInterface $newsletter, SubscriberInterface $subscriber, $message)
 {
     /* @var $log \Ibrows\Bundle\NewsletterBundle\Model\Log\LogInterface */
     $log = new $className();
     $log->setNewsletterId($newsletter->getId())->setSubscriberId($subscriber->getId())->setSubscriberEmail($subscriber->getEmail())->setMessage($message)->setMandantName($this->mandantName);
     if ($subscriber instanceof SubscriberGenderTitleInterface) {
         $log->setSubscriberCompanyname($subscriber->getCompanyname())->setSubscriberFirstname($subscriber->getFirstname())->setSubscriberGender($subscriber->getGender())->setSubscriberLastname($subscriber->getLastname())->setSubscriberTitle($subscriber->getTitle());
     }
     if ($subscriber instanceof SubscriberLocaleInterface) {
         $log->setSubscriberLocale($subscriber->getLocale());
     }
     return $log;
 }
 public function __construct(NewsletterInterface $newsletter, SendSettingsInterface $sendSettings)
 {
     parent::__construct();
     $this->setSubject($newsletter->getSubject());
     $this->setSenderName($newsletter->getSenderName());
     $this->setSenderMail($newsletter->getSenderMail());
     $this->setReturnMail($newsletter->getReturnMail());
     $this->setUsername($sendSettings->getUsername());
     $this->setPassword($sendSettings->getPassword());
     $this->setHost($sendSettings->getHost());
     $this->setPort($sendSettings->getPort());
     $this->setEncryption($sendSettings->getEncryption());
     $this->setAuthMode($sendSettings->getAuthMode());
     $this->setScheduled($sendSettings->getStarttime());
     $this->setNewsletterId($newsletter->getId());
     $this->salt = $newsletter->getMandant()->getSalt();
 }
 /**
  * @param NewsletterInterface $newsletter
  * @param NewsletterInterface $cloneNewsletter
  */
 protected function cloneNewsletterBlocks(NewsletterInterface $newsletter, NewsletterInterface $cloneNewsletter)
 {
     foreach ($cloneNewsletter->getBlocks() as $parentBlock) {
         $cloneParentBlock = clone $parentBlock;
         $cloneParentBlock->setBlocks(array());
         $newsletter->addBlock($cloneParentBlock);
         $provider = $this->getBlockProviderManager()->get($cloneParentBlock->getProviderName());
         $provider->updateClonedBlock($cloneParentBlock);
         $this->loopCloneNewsletterBlocks($parentBlock, $cloneParentBlock);
     }
 }
 /**
  * @param  NewsletterInterface   $newsletter
  * @param  string                $hash
  * @return SubscriberInterface
  * @throws NotFoundHttpException
  */
 protected function getSubscriberByHash(NewsletterInterface $newsletter, $hash)
 {
     $subscriber = null;
     foreach ($newsletter->getSubscribers() as $newsletterSubscriber) {
         if ($newsletterSubscriber->getHash() == $hash) {
             return $newsletterSubscriber;
         }
     }
     throw $this->createNotFoundException("Subscriber with hash {$hash} not found in newsletter #" . $newsletter->getId());
 }
 /**
  * @param  MandantInterface    $mandant
  * @param  NewsletterInterface $newsletter
  * @param  SubscriberInterface $subscriber
  * @param $context
  * @return string
  */
 public function unsubscribelink(MandantInterface $mandant, NewsletterInterface $newsletter, SubscriberInterface $subscriber, $context)
 {
     return $this->router->generate('ibrows_newsletter_unsubscribe', array('mandantHash' => $mandant->getHash(), 'newsletterHash' => $newsletter->getHash(), 'subscriberHash' => $subscriber->getHash(), 'context' => $context), true);
 }
 public function persistNewsletter($name, NewsletterInterface $newsletter)
 {
     $manager = $this->getObjectManager($name);
     $newsletter->setMandant($this->get($name));
     $manager->persist($newsletter);
     $manager->flush();
     return $newsletter;
 }