added hook_simplenews_subscriber_delete to simplenews_mailjet_subscriptions
This commit is contained in:
parent
5ff92a7063
commit
6f87574096
|
@ -20,7 +20,7 @@ index 2512a39..d4b0440 100644
|
|||
- simplenews:simplenews
|
||||
+ - mailjet:mailjet
|
||||
diff --git a/simplenews_mailjet_subscriptions.module b/simplenews_mailjet_subscriptions.module
|
||||
index 09abe13..4b2ee58 100644
|
||||
index 09abe13..a481713 100644
|
||||
--- a/simplenews_mailjet_subscriptions.module
|
||||
+++ b/simplenews_mailjet_subscriptions.module
|
||||
@@ -7,7 +7,7 @@
|
||||
|
@ -54,7 +54,7 @@ index 09abe13..4b2ee58 100644
|
|||
}
|
||||
|
||||
/**
|
||||
@@ -51,19 +51,19 @@ function simplenews_mailjet_subscriptions_simplenews_subscribe(Subscriber $subsc
|
||||
@@ -51,19 +51,40 @@ function simplenews_mailjet_subscriptions_simplenews_subscribe(Subscriber $subsc
|
||||
function simplenews_mailjet_subscriptions_simplenews_unsubscribe(Subscriber $subscriber, string $subscription) {
|
||||
$entities = SimplenewsMailjetSubscriptionEntity::loadMultiple();
|
||||
foreach ((array) $entities as $entity) {
|
||||
|
@ -74,6 +74,27 @@ index 09abe13..4b2ee58 100644
|
|||
}
|
||||
}
|
||||
+ // \Drupal::service('simplenews_mailjet_subscriptions.utilities')->unsubscribeUser($subscriber, $subscription);
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
+ * Act after a subscriber has been deleted.
|
||||
+ *
|
||||
+ * @param \Drupal\simplenews\Entity\Subscriber $subscriber
|
||||
+ * The subscriber object including all subscriptions of this user.
|
||||
+ *
|
||||
+ * @ingroup subscriber
|
||||
+ */
|
||||
+function simplenews_mailjet_subscriptions_simplenews_subscriber_delete(Subscriber $subscriber) {
|
||||
+ $entities = SimplenewsMailjetSubscriptionEntity::loadMultiple();
|
||||
+ foreach ((array) $entities as $entity) {
|
||||
+ $listID = $entity->getID();
|
||||
+ $table = $entity->get('mapping_table');
|
||||
+ if (is_array($table)) {
|
||||
+ foreach ($table as $category) {
|
||||
+ \Drupal::service('simplenews_mailjet_subscriptions.utilities')->unsubscribeUser($listID, $subscriber, $category);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue