Skip to content

Commit

Permalink
[FEATURE] Make it possible to override global settings
Browse files Browse the repository at this point in the history
  • Loading branch information
georgringer committed Mar 22, 2022
1 parent 9c84efa commit 1b90b7f
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
18 changes: 16 additions & 2 deletions Classes/Finishers/SendinblueFinisher.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected function addEntryToSendInBlue(): void
$createContact
->setEmail($this->parseOption('email'))
->setIncludeListIds($this->getEnrichedListIds())
->setTemplateId($this->extensionConfiguration->getDoiTemplateId())
->setTemplateId($this->getDoiTemplateId())
->setAttributes($this->getAttributes())
->setRedirectionUrl($this->getRedirectionUrl());
$apiInstance->createDoiContact($createContact);
Expand All @@ -87,14 +87,28 @@ protected function addEntryToSendInBlue(): void
}
}

protected function getDoiTemplateId(): int
{
$doiTemplateId = (int)$this->parseOption('doiTemplateId');
if ($doiTemplateId) {
return $doiTemplateId;
}
return $this->extensionConfiguration->getDoiTemplateId();
}

protected function newsletterSubscriptionIsEnabled(): bool
{
return (bool)$this->parseOption('enabled');
}

protected function getEnrichedListIds(): array
{
$lists = $this->extensionConfiguration->getDefaultListIds();
$defaultListsFromForm = $this->parseOption('defaultListIds');
if ($defaultListsFromForm !== null) {
$lists = GeneralUtility::intExplode(',', (string)$defaultListsFromForm, true);
} else {
$lists = $this->extensionConfiguration->getDefaultListIds();
}

$additionalLists = $this->parseOption('additionalListIds');
if ($additionalLists) {
Expand Down
12 changes: 12 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,18 @@ Getting started with that is also a bit tricky for the 1st time. This is documen
1. The DOI template needs to be tagged with `optin`.
2. The button in the DOI template for triggering the confirmation must have as link value `{{ doubleoptin }}`.

### Override global configuration per form

The following configurations can be used to override the global settings

```yaml
-
options:
doiTemplateId: '14'
defaultListIds: '12,34'
identifier: Sendinblue
```
## Author
This extension has been created by [StudioMitte](https://studiomitte.com)
Expand Down
4 changes: 4 additions & 0 deletions Resources/Private/Example/sendinblue-example.form.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ finishers:
email: '{text-2}'
tracking: trackingvalue
additionalListIds: '{multicheckbox-1}'

# override global settings
# doiTemplateId: '14'
# defaultListIds: '12,34'
identifier: Sendinblue
-
options:
Expand Down
2 changes: 1 addition & 1 deletion ext_emconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
'author_company' => 'StudioMitte',
'state' => 'stable',
'clearCacheOnLoad' => 0,
'version' => '1.0.0',
'version' => '1.1.0',
'constraints' => [
'depends' => [
'typo3' => '10.4.0-10.4.99',
Expand Down

0 comments on commit 1b90b7f

Please sign in to comment.