|
@@ -301,6 +301,62 @@ index 98342b5..f67ba96 100644
|
|
|
|
|
|
$form['add_subscription'] = [
|
|
|
'#type' => 'submit',
|
|
|
+diff --git a/src/Plugin/RulesAction/UnsubscribeFromList.php b/src/Plugin/RulesAction/UnsubscribeFromList.php
|
|
|
+new file mode 100644
|
|
|
+index 0000000..c6a5a77
|
|
|
+--- /dev/null
|
|
|
++++ b/src/Plugin/RulesAction/UnsubscribeFromList.php
|
|
|
+@@ -0,0 +1,49 @@
|
|
|
++<?php
|
|
|
++
|
|
|
++namespace Drupal\simplenews_mailjet_subscriptions\Plugin\RulesAction;
|
|
|
++
|
|
|
++use Drupal\rules\Core\RulesActionBase;
|
|
|
++use Drupal\simplenews\SubscriberInterface;
|
|
|
++
|
|
|
++/**
|
|
|
++ * Provides a 'Unsubscribe' action.
|
|
|
++ *
|
|
|
++ * @RulesAction(
|
|
|
++ * id = "rules_simplenews_mailjet_subscriptions_unsubscribe_from_list",
|
|
|
++ * label = @Translation("Unsubscribe from newsletter, giving mailjet listID and email"),
|
|
|
++ * category = @Translation("Simplenews Mailjet Subscriptions"),
|
|
|
++ * context_definitions = {
|
|
|
++ * "listID" = @ContextDefinition("integer",
|
|
|
++ * label = @Translation("Mailjet list ID"),
|
|
|
++ * description = @Translation("Specifies the mailjet list ID from which simplenews list will be found and email will be unsubscribed from.")
|
|
|
++ * ),
|
|
|
++ * "email" = @ContextDefinition("string",
|
|
|
++ * label = @Translation("Subscriber email"),
|
|
|
++ * description = @Translation("Specifies the email to unsubscribe.")
|
|
|
++ * )
|
|
|
++ * }
|
|
|
++ * )
|
|
|
++ */
|
|
|
++class UnsubscribeFromList extends RulesActionBase {
|
|
|
++
|
|
|
++ /**
|
|
|
++ * Deletes the Entity.
|
|
|
++ *
|
|
|
++ * @param integer listID
|
|
|
++ * The mailjet list to unsubcsribe from.
|
|
|
++ *
|
|
|
++ * @param string email
|
|
|
++ * The email to unsubcribe.
|
|
|
++ */
|
|
|
++ protected function doExecute(integer $listID, string $email) {
|
|
|
++ $l = $listID;
|
|
|
++ $e = $email;
|
|
|
++ \Drupal::logger('simplenews_mailjet_subscriptions')->info("Unsubscribe webhook triggered for listID: " . $listID . ", and email: " . $email . ".");
|
|
|
++ // find corresponding simplenews list from mailjet listID
|
|
|
++
|
|
|
++ // get subscriber entity
|
|
|
++
|
|
|
++ // unsubscribe subscriber from simplenews list
|
|
|
++ }
|
|
|
++
|
|
|
++}
|
|
|
+\ No newline at end of file
|
|
|
diff --git a/src/SimplenewsMailjetSubscriptionsInterface.php b/src/SimplenewsMailjetSubscriptionsInterface.php
|
|
|
index c727d26..37c082d 100644
|
|
|
--- a/src/SimplenewsMailjetSubscriptionsInterface.php
|