Skip to content

Commit

Permalink
Merge pull request #7 from studiomitte/brevo
Browse files Browse the repository at this point in the history
[TASK] Switch to brevo
  • Loading branch information
georgringer authored Sep 20, 2023
2 parents 8664623 + 75d1d43 commit d4c7b72
Show file tree
Hide file tree
Showing 18 changed files with 118 additions and 121 deletions.
8 changes: 4 additions & 4 deletions Classes/ApiWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@

declare(strict_types=1);

namespace StudioMitte\Sendinblue;
namespace StudioMitte\Brevo;

/*
* This file is part of TYPO3 CMS-based extension "sendinblue" by StudioMitte.
* This file is part of TYPO3 CMS-based extension "brevo" by StudioMitte.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*/

use Brevo\Client\Configuration;
use StudioMitte\Sendinblue\Configuration as ExtensionConfiguration;
use StudioMitte\Brevo\Configuration as ExtensionConfiguration;

/**
* Wrapper for the sendinblue api giving back a pre-configured API
* Wrapper for the brevo api giving back a pre-configured API
*/
class ApiWrapper
{
Expand Down
8 changes: 4 additions & 4 deletions Classes/Command/TestCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

declare(strict_types=1);

namespace StudioMitte\Sendinblue\Command;
namespace StudioMitte\Brevo\Command;

/*
* This file is part of TYPO3 CMS-based extension "sendinblue" by StudioMitte.
* This file is part of TYPO3 CMS-based extension "brevo" by StudioMitte.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*/

use Brevo\Client\Api\ContactsApi;
use StudioMitte\Sendinblue\ApiWrapper;
use StudioMitte\Brevo\ApiWrapper;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
Expand All @@ -30,7 +30,7 @@ class TestCommand extends Command
protected function configure()
{
$this
->setDescription('Sendinblue demo');
->setDescription('Brevo demo');
}

/**
Expand Down
6 changes: 3 additions & 3 deletions Classes/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

declare(strict_types=1);

namespace StudioMitte\Sendinblue;
namespace StudioMitte\Brevo;

/*
* This file is part of TYPO3 CMS-based extension "sendinblue" by StudioMitte.
* This file is part of TYPO3 CMS-based extension "brevo" by StudioMitte.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
Expand Down Expand Up @@ -52,7 +52,7 @@ class Configuration
public function __construct()
{
try {
$settings = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('sendinblue');
$settings = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('brevo');

foreach (['apiKey', 'attributeFirstName', 'attributeLastName', 'attributeTracking'] as $stringField) {
$this->$stringField = $settings[$stringField] ?? '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

declare(strict_types=1);

namespace StudioMitte\Sendinblue\Finishers;
namespace StudioMitte\Brevo\Finishers;

/*
* This file is part of TYPO3 CMS-based extension "sendinblue" by StudioMitte.
* This file is part of TYPO3 CMS-based extension "brevo" by StudioMitte.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
Expand All @@ -17,15 +17,15 @@
use Brevo\Client\Api\ContactsApi;
use Brevo\Client\Model\CreateContact;
use Brevo\Client\Model\CreateDoiContact;
use StudioMitte\Sendinblue\ApiWrapper;
use StudioMitte\Sendinblue\Configuration;
use StudioMitte\Brevo\ApiWrapper;
use StudioMitte\Brevo\Configuration;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Form\Domain\Finishers\AbstractFinisher;

/**
* Finisher for EXT:form sending the data to sendinblue
* Finisher for EXT:form sending the data to brevo
*/
class SendinblueFinisher extends AbstractFinisher implements LoggerAwareInterface
class BrevoFinisher extends AbstractFinisher implements LoggerAwareInterface
{
use LoggerAwareTrait;

Expand All @@ -44,19 +44,19 @@ protected function executeInternal(): void
return;
}

$this->addEntryToSendInBlue() ? $this->setFinisherSubscribedVariable(1) : $this->setFinisherSubscribedVariable(0);
$this->addEntryToBrevo() ? $this->setFinisherSubscribedVariable(1) : $this->setFinisherSubscribedVariable(0);
}

protected function setFinisherSubscribedVariable(int $returnValue): void
{
$this->finisherContext->getFinisherVariableProvider()->add(
'sendinblue',
'brevo',
'data.subscribed',
$returnValue
);
}

protected function addEntryToSendInBlue(): bool
protected function addEntryToBrevo(): bool
{
try {
$apiInstance = $this->getApi();
Expand Down Expand Up @@ -152,7 +152,7 @@ protected function getAttributes(): object
}

// additional attribute mappings
$additionalAttributes = $this->parseOption('additionalAttributes');
$additionalAttributes = (array)($this->parseOption('additionalAttributes') ?? []);
foreach ($additionalAttributes as $key => $value) {
$attributes[$key] = $value;
}
Expand Down
14 changes: 7 additions & 7 deletions Classes/Report/IntegrationReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

declare(strict_types=1);

namespace StudioMitte\Sendinblue\Report;
namespace StudioMitte\Brevo\Report;

/*
* This file is part of TYPO3 CMS-based extension "sendinblue" by StudioMitte.
* This file is part of TYPO3 CMS-based extension "brevo" by StudioMitte.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
Expand All @@ -17,7 +17,7 @@
use Brevo\Client\Api\TransactionalEmailsApi;
use Brevo\Client\ApiException;
use Brevo\Client\Model\GetAccount;
use StudioMitte\Sendinblue\ApiWrapper;
use StudioMitte\Brevo\ApiWrapper;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\Exception\InvalidExtensionNameException;
use TYPO3\CMS\Fluid\View\StandaloneView;
Expand All @@ -41,14 +41,14 @@ public function getReport(): string
// Rendering of the output via fluid
$view = GeneralUtility::makeInstance(StandaloneView::class);
$view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName(
'EXT:sendinblue/Resources/Private/Templates/IntegrationReport.html'
'EXT:brevo/Resources/Private/Templates/IntegrationReport.html'
));

$view->assignMultiple([
'account' => $this->getAccountInformation(),
'contacts' => $this->getContactInformation(),
'emails' => $this->getTransactionalEmailInformation(),
'lll' => 'LLL:EXT:sendinblue/Resources/Private/Language/locallang_report.xlf:'
'lll' => 'LLL:EXT:brevo/Resources/Private/Language/locallang_report.xlf:'
]);

return $view->render();
Expand Down Expand Up @@ -98,12 +98,12 @@ public function getIdentifier(): string

public function getTitle(): string
{
return 'LLL:EXT:sendinblue/Resources/Private/Language/locallang_report.xlf:report.title';
return 'LLL:EXT:brevo/Resources/Private/Language/locallang_report.xlf:report.title';
}

public function getDescription(): string
{
return 'LLL:EXT:sendinblue/Resources/Private/Language/locallang_report.xlf:report.description';
return 'LLL:EXT:brevo/Resources/Private/Language/locallang_report.xlf:report.description';
}

public function getIconIdentifier(): string
Expand Down
6 changes: 3 additions & 3 deletions Configuration/Services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ services:
autoconfigure: true
public: false

StudioMitte\Sendinblue\Command\TestCommand:
StudioMitte\Brevo\Command\TestCommand:
tags:
- name: 'console.command'
command: 'sendinblue:test'
command: 'brevo:test'
schedulable: false

StudioMitte\Sendinblue\Report\IntegrationReport:
StudioMitte\Brevo\Report\IntegrationReport:
tags:
- name: reports.report
42 changes: 21 additions & 21 deletions Configuration/Yaml/FormSetup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,30 @@ TYPO3:
standard:
formEditor:
translationFiles:
1483353712: 'EXT:sendinblue/Resources/Private/Language/Form.xlf'
1483353712: 'EXT:brevo/Resources/Private/Language/Form.xlf'
formElementsDefinition:
Form:
formEditor:
editors:
900:
selectOptions:
1483353712:
value: 'Sendinblue'
label: 'finisher.Sendinblue.label'
value: 'Brevo'
label: 'finisher.Brevo.label'
propertyCollections:
finishers:
# add finisher fields
1483353712:
identifier: 'Sendinblue'
identifier: 'Brevo'
editors:
100:
identifier: header
label: 'finisher.Sendinblue.label'
label: 'finisher.Brevo.label'
templateName: 'Inspector-CollectionElementHeaderEditor'
110:
identifier: 'enabled'
templateName: 'Inspector-TextEditor'
label: 'finisher.Sendinblue.field.enable'
label: 'finisher.Brevo.field.enable'
propertyPath: 'options.enabled'
enableFormelementSelectionButton: true
propertyValidators:
Expand All @@ -37,7 +37,7 @@ TYPO3:
120:
identifier: 'email'
templateName: 'Inspector-TextEditor'
label: 'finisher.Sendinblue.field.email'
label: 'finisher.Brevo.field.email'
propertyPath: 'options.email'
enableFormelementSelectionButton: true
propertyValidators:
Expand All @@ -46,41 +46,41 @@ TYPO3:
130:
identifier: 'firstName'
templateName: 'Inspector-TextEditor'
label: 'finisher.Sendinblue.field.firstName'
label: 'finisher.Brevo.field.firstName'
propertyPath: 'options.firstName'
enableFormelementSelectionButton: true
propertyValidators:
20: 'FormElementIdentifierWithinCurlyBracesInclusive'
131:
identifier: 'lastName'
templateName: 'Inspector-TextEditor'
label: 'finisher.Sendinblue.field.lastName'
label: 'finisher.Brevo.field.lastName'
propertyPath: 'options.lastName'
enableFormelementSelectionButton: true
propertyValidators:
20: 'FormElementIdentifierWithinCurlyBracesInclusive'
135:
identifier: 'additionalListIds'
templateName: 'Inspector-TextEditor'
label: 'finisher.Sendinblue.field.additionalListIds'
label: 'finisher.Brevo.field.additionalListIds'
propertyPath: 'options.additionalListIds'
enableFormelementSelectionButton: true
propertyValidators:
20: 'FormElementIdentifierWithinCurlyBracesInclusive'
150:
identifier: 'tracking'
templateName: 'Inspector-TextEditor'
label: 'finisher.Sendinblue.field.tracking'
label: 'finisher.Brevo.field.tracking'
propertyPath: 'options.tracking'
9999:
identifier: 'removeButton'
templateName: 'Inspector-RemoveElementEditor'
finishersDefinition:
Sendinblue:
implementationClassName: 'StudioMitte\Sendinblue\Finishers\SendinblueFinisher'
Brevo:
implementationClassName: 'StudioMitte\Brevo\Finishers\BrevoFinisher'
formEditor:
iconIdentifier: 'form-finisher'
label: 'finisher.Sendinblue.label'
label: 'finisher.Brevo.label'
predefinedDefaults:
options:
enabled: ''
Expand All @@ -91,29 +91,29 @@ TYPO3:
tracking: 'trackingvalue'
# displayed when overriding finisher settings
FormEngine:
label: 'finisher.Sendinblue.label'
label: 'finisher.Brevo.label'
elements:
enabled:
label: 'finisher.Sendinblue.field.enable'
label: 'finisher.Brevo.field.enable'
config:
type: 'check'
tracking:
label: 'finisher.Sendinblue.field.tracking'
label: 'finisher.Brevo.field.tracking'
config:
type: 'text'
email:
label: 'finisher.Sendinblue.field.email'
label: 'finisher.Brevo.field.email'
config:
type: 'text'
firstName:
label: 'finisher.Sendinblue.field.firstName'
label: 'finisher.Brevo.field.firstName'
config:
type: 'text'
lastName:
label: 'finisher.Sendinblue.field.lastName'
label: 'finisher.Brevo.field.lastName'
config:
type: 'text'
additionalListIds:
label: 'finisher.Sendinblue.field.additionalListIds'
label: 'finisher.Brevo.field.additionalListIds'
config:
type: 'text'
Loading

0 comments on commit d4c7b72

Please sign in to comment.