/** * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state, SubscriberInterface $subscriber = NULL) { $form = parent::buildForm($form, $form_state); $form['question'] = array('#markup' => '<p>' . t('Are you sure you want to confirm the following subscription changes for %user?', array('%user' => simplenews_mask_mail($subscriber->getMail()))) . "<p>\n"); /** @var \Drupal\simplenews\Subscription\SubscriptionManagerInterface $subscription_manager */ $subscription_manager = \Drupal::service('simplenews.subscription_manager'); $form['changes'] = array('#theme' => 'item_list', '#items' => $subscription_manager->getChangesList($subscriber)); $form['subscriber'] = array('#type' => 'value', '#value' => $subscriber); return $form; }
/** * Add a mail confirmation or fetch them. * * @param string $action * The confirmation type, either subscribe or unsubscribe. * @param \Drupal\simplenews\SubscriberInterface $subscriber * The subscriber object. * @param \Drupal\simplenews\NewsletterInterface $newsletter * The newsletter object. */ protected function addConfirmation($action, SubscriberInterface $subscriber, NewsletterInterface $newsletter) { $this->confirmations[$subscriber->getMail()][$newsletter->id()] = $action; }
/** * {@inheritdoc} */ public function sendCombinedConfirmation(SubscriberInterface $subscriber) { $params['from'] = $this->getFrom(); $params['context']['simplenews_subscriber'] = $subscriber; // Send multiple if there is more than one change for this subscriber // single otherwise. $use_combined = $this->config->get('subscription.use_combined'); $changes = $subscriber->getChanges(); if (count($changes) > 1 && $use_combined != 'never' || $use_combined == 'always') { $key = 'subscribe_combined'; $this->mailManager->mail('simplenews', $key, $subscriber->getMail(), $subscriber->getLangcode(), $params, $params['from']['address']); } else { foreach ($changes as $newsletter_id => $key) { $params['context']['newsletter'] = simplenews_newsletter_load($newsletter_id); $this->mailManager->mail('simplenews', $key, $subscriber->getMail(), $subscriber->getLangcode(), $params, $params['from']['address']); } } }