From 77f6e5d706d3b85058f25ae5b61f85374bd0b2db Mon Sep 17 00:00:00 2001 From: Henrik Ziegenhain Date: Wed, 6 May 2026 08:00:53 +0200 Subject: [PATCH] [FEATURE] make DOI flag overrideable resolves #22 --- Classes/Finishers/BrevoFinisher.php | 20 ++++++++++++++++++- Readme.md | 3 ++- .../Private/Example/brevo-example.form.yaml | 1 + 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Classes/Finishers/BrevoFinisher.php b/Classes/Finishers/BrevoFinisher.php index d5a8629..13403cc 100644 --- a/Classes/Finishers/BrevoFinisher.php +++ b/Classes/Finishers/BrevoFinisher.php @@ -67,7 +67,7 @@ protected function addEntryToBrevo(): bool { try { $apiInstance = $this->getApi(); - if ($this->extensionConfiguration->isDoi()) { + if ($this->isDoiEnabled()) { $createContact = new CreateDoiContact(); $createContact ->setEmail($this->parseOption('email')) @@ -142,6 +142,24 @@ protected function getEnrichedListIds(): array return array_unique($lists); } + /** + * Check if DOI is enabled. + * By default, DOI is enabled via the extension configuration. + * Optionally, it can be disabled via the form configuration. + * + * @return bool + */ + protected function isDoiEnabled(): bool + { + $doiEnabled = $this->extensionConfiguration->isDoi(); + + if ($this->parseOption('doi') !== null) { + $doiEnabled = (bool)$this->parseOption('doi'); + } + + return $doiEnabled; + } + /** * @return object */ diff --git a/Readme.md b/Readme.md index b729546..2bf0fbd 100644 --- a/Readme.md +++ b/Readme.md @@ -16,7 +16,7 @@ Head over to the extension configuration and provide all settings you need: - *Partner Key*: currently not in use - Default Lists*: Add IDs of brevo contact lists which are added to every contact - **DOI** - - *Enable double optin*: Please always use double opt in! + - *Enable double optin*: Please always use double opt in! Additionally, it can be overwritten by form configuration. - *Page ID for redirect*: Page which a user is sent to after confirming double opt in - *DOI Template*: Id of brevo template which is used for DOI mails. - **Attributes** @@ -67,6 +67,7 @@ The following configurations can be used to override the global settings options: doiTemplateId: '14' defaultListIds: '12,34' + doi: false identifier: Brevo ``` diff --git a/Resources/Private/Example/brevo-example.form.yaml b/Resources/Private/Example/brevo-example.form.yaml index 7766f21..142e1da 100644 --- a/Resources/Private/Example/brevo-example.form.yaml +++ b/Resources/Private/Example/brevo-example.form.yaml @@ -21,6 +21,7 @@ finishers: # override global settings # doiTemplateId: '14' # defaultListIds: '12,34' + # doi: false identifier: Brevo - options: