public function SubscriptionManager::sendConfirmations in Simplenews 8
Same name and namespace in other branches
- 8.2 src/Subscription/SubscriptionManager.php \Drupal\simplenews\Subscription\SubscriptionManager::sendConfirmations()
- 3.x src/Subscription/SubscriptionManager.php \Drupal\simplenews\Subscription\SubscriptionManager::sendConfirmations()
Send confirmations for previous subscription and unsubscription requests.
Return value
int The number of confirmations that were sent.
Overrides SubscriptionManagerInterface::sendConfirmations
1 call to SubscriptionManager::sendConfirmations()
- SubscriptionManager::destruct in src/
Subscription/ SubscriptionManager.php - Performs destruct operations.
File
- src/
Subscription/ SubscriptionManager.php, line 255
Class
- SubscriptionManager
- Default subscription manager.
Namespace
Drupal\simplenews\SubscriptionCode
public function sendConfirmations() {
foreach ($this->confirmations as $mail => $changes) {
$subscriber = simplenews_subscriber_load_by_mail($mail);
if (!$subscriber) {
$subscriber = Subscriber::create(array());
$subscriber
->setMail($mail);
$subscriber
->setLangcode($this->languageManager
->getCurrentLanguage());
$subscriber
->save();
}
$subscriber
->setChanges($changes);
$this->mailer
->sendCombinedConfirmation($subscriber);
// Save the changes in the subscriber if there is a real subscriber object.
if ($subscriber && $subscriber
->id()) {
$subscriber
->save();
}
}
$sent = !empty($this->confirmations);
$this->confirmations = array();
return $sent;
}