public function subscribe(NewsletterEvent $event) { // test if the email is already registered and unsubscribed if (null === ($newsletter = NewsletterQuery::create()->findOneByEmail($event->getEmail()))) { $newsletter = new NewsletterModel(); } $newsletter->setEmail($event->getEmail())->setFirstname($event->getFirstname())->setLastname($event->getLastname())->setLocale($event->getLocale())->setUnsubscribed(false)->save(); $event->setNewsletter($newsletter); }
public function subscribe(NewsletterEvent $event) { // test if the email is already registered and unsubscribed if (null === ($newsletter = NewsletterQuery::create()->findOneByEmail($event->getEmail()))) { $newsletter = new NewsletterModel(); } $newsletter->setEmail($event->getEmail())->setFirstname($event->getFirstname())->setLastname($event->getLastname())->setLocale($event->getLocale())->setUnsubscribed(false)->save(); $event->setNewsletter($newsletter); if (ConfigQuery::getNotifyNewsletterSubscription()) { $this->dispatcher->dispatch(TheliaEvents::NEWSLETTER_CONFIRM_SUBSCRIPTION, $event); } }
public function subscribe(NewsletterEvent $event) { $newsletter = new NewsletterModel(); $newsletter->setEmail($event->getEmail())->setFirstname($event->getFirstname())->setLastname($event->getLastname())->setLocale($event->getLocale())->save(); $event->setNewsletter($newsletter); }