Skip to content

Commit

Permalink
Replace depreated SendinBlue naming and package with Brevo
Browse files Browse the repository at this point in the history
  • Loading branch information
gruberro committed Feb 11, 2024
1 parent b01747b commit a5ec05f
Show file tree
Hide file tree
Showing 16 changed files with 108 additions and 108 deletions.
2 changes: 1 addition & 1 deletion DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function getConfigTreeBuilder(): TreeBuilder
->info('Enable csrf protection for dynamic forms.')
->defaultFalse()
->end()
->scalarNode('sendinblue_api_key')->defaultValue(null)->end()
->scalarNode('brevo_api_key')->defaultValue(null)->end()
->scalarNode('mailchimp_api_key')->defaultValue(null)->end()
->scalarNode('mailchimp_subscribe_status')->defaultValue('subscribed')->end()
->enumNode('media_collection_strategy')
Expand Down
10 changes: 5 additions & 5 deletions DependencyInjection/SuluFormExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public function load(array $configs, ContainerBuilder $container): void
$container->setParameter('sulu_form.ajax_templates', $config['ajax_templates']);
$container->setParameter('sulu_form.dynamic_widths', $config['dynamic_widths']);
$container->setParameter('sulu_form.dynamic_auto_title', $config['dynamic_auto_title']);
$container->setParameter('sulu_form.sendinblue_api_key', $config['sendinblue_api_key']);
$container->setParameter('sulu_form.brevo_api_key', $config['brevo_api_key']);
$container->setParameter('sulu_form.mailchimp_api_key', $config['mailchimp_api_key']);
$container->setParameter('sulu_form.mailchimp_subscribe_status', $config['mailchimp_subscribe_status']);
$container->setParameter('sulu_form.dynamic_lists.config', $config['dynamic_lists']);
Expand Down Expand Up @@ -196,12 +196,12 @@ public function load(array $configs, ContainerBuilder $container): void
$definition->setDeprecated(true, 'The "%service_id%" is deprecated use the mailer configuration instead.');
}

if ($config['sendinblue_api_key']) {
if (!\class_exists(\SendinBlue\Client\Configuration::class)) {
throw new \LogicException('You need to install the "sendinblue/api-v3-sdk" package to use the sendinblue type.');
if ($config['brevo_api_key']) {
if (!\class_exists(\Brevo\Client\Configuration::class)) {
throw new \LogicException('You need to install the "getbrevo/brevo-php" package to use the Brevo type.');
}

$loader->load('type_sendinblue.xml');
$loader->load('type_brevo.xml');
}

if ($config['mailchimp_api_key']) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@

namespace Sulu\Bundle\FormBundle\Dynamic\Helper;

use SendinBlue\Client\Api\ContactsApi;
use SendinBlue\Client\Configuration;
use Brevo\Client\Api\ContactsApi;
use Brevo\Client\Configuration;

/**
* @final
*
* @internal
*/
class SendinblueListSelect
class BrevoListSelect
{
/**
* @var ContactsApi|null
Expand All @@ -39,7 +39,7 @@ public function __construct(?string $apiKey)
}

/**
* Returns array of Sendinblue lists of given account defined by the API key.
* Returns array of Brevo lists of given account defined by the API key.
*
* @return mixed[]
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@

namespace Sulu\Bundle\FormBundle\Dynamic\Helper;

use SendinBlue\Client\Api\TransactionalEmailsApi;
use SendinBlue\Client\Configuration;
use Brevo\Client\Api\TransactionalEmailsApi;
use Brevo\Client\Configuration;

/**
* @final
*
* @internal
*/
class SendinblueMailTemplateSelect
class BrevoMailTemplateSelect
{
/**
* @var TransactionalEmailsApi|null
Expand All @@ -39,7 +39,7 @@ public function __construct(?string $apiKey)
}

/**
* Returns array of Sendinblue mail templates of given account defined by the API key.
* Returns array of Brevo mail templates of given account defined by the API key.
*
* @return mixed[]
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
use Symfony\Component\Form\FormBuilderInterface;

/**
* The Sendinblue form field type.
* The Brevo form field type.
*/
class SendinblueType implements FormFieldTypeInterface
class BrevoType implements FormFieldTypeInterface
{
public function getConfiguration(): FormFieldTypeConfiguration
{
return new FormFieldTypeConfiguration(
'sulu_form.type.sendinblue',
__DIR__ . '/../../Resources/config/form-fields/field_sendinblue.xml',
'sulu_form.type.brevo',
__DIR__ . '/../../Resources/config/form-fields/field_brevo.xml',
'special'
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
namespace Sulu\Bundle\FormBundle\Event;

use GuzzleHttp\ClientInterface;
use SendinBlue\Client\Api\ContactsApi;
use SendinBlue\Client\Configuration;
use SendinBlue\Client\Model\CreateDoiContact;
use Brevo\Client\Api\ContactsApi;
use Brevo\Client\Configuration;
use Brevo\Client\Model\CreateDoiContact;
use Sulu\Bundle\FormBundle\Entity\Dynamic;
use Sulu\Bundle\MarkupBundle\Markup\Link\LinkProviderPoolInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
Expand All @@ -25,7 +25,7 @@
*
* @internal
*/
class SendinblueListSubscriber implements EventSubscriberInterface
class BrevoListSubscriber implements EventSubscriberInterface
{
/**
* @var RequestStack
Expand Down Expand Up @@ -101,7 +101,7 @@ public function listSubscribe(FormSavePostEvent $event): void
$lastName = $field['value'];
} elseif ('email' === $field['type'] && !$email) {
$email = $field['value'];
} elseif ('sendinblue' == $field['type'] && $field['value']) {
} elseif ('brevo' == $field['type'] && $field['value']) {
/** @var string|int|null $listId */
$mailTemplateId = $field['options']['mailTemplateId'] ?? null;
/** @var int|null $listId */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,32 @@
xpointer(//sulu:property)"/>
<property name="options/listId" type="single_select" mandatory="true">
<meta>
<title>sulu_form.sendinblue_list</title>
<title>sulu_form.brevo_list</title>
</meta>
<params>
<param
name="values"
type="expression"
value="service('sulu_form.dynamic.sendinblue_list_select').getValues()"
value="service('sulu_form.dynamic.brevo_list_select').getValues()"
/>
</params>
</property>
<property name="options/mailTemplateId" type="single_select" mandatory="true">
<meta>
<title>sulu_form.sendinblue_mail_template</title>
<title>sulu_form.brevo_mail_template</title>
</meta>
<params>
<param
name="values"
type="expression"
value="service('sulu_form.dynamic.sendinblue_mail_template_select').getValues()"
value="service('sulu_form.dynamic.brevo_mail_template_select').getValues()"
/>
</params>
</property>

<property name="options/redirectLink" type="link" mandatory="false">
<meta>
<title>sulu_form.sendinblue_redirection_url</title>
<title>sulu_form.brevo_redirection_url</title>
</meta>
<params>
<param name="types" type="collection">
Expand Down
27 changes: 27 additions & 0 deletions Resources/config/type_brevo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" ?>

<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="sulu_form.subscriber.brevo_list_subscriber" class="Sulu\Bundle\FormBundle\Event\BrevoListSubscriber">
<argument type="service" id="request_stack"/>
<argument>%sulu_form.brevo_api_key%</argument>
<argument>null</argument>
<argument type="service" id="sulu_markup.link_tag.provider_pool"/>
<tag name="kernel.event_subscriber" />
</service>

<service id="sulu_form.dynamic.type_brevo" class="Sulu\Bundle\FormBundle\Dynamic\Types\BrevoType">
<tag name="sulu_form.dynamic.type" alias="brevo"/>
</service>

<service id="sulu_form.dynamic.brevo_list_select" class="Sulu\Bundle\FormBundle\Dynamic\Helper\BrevoListSelect" public="true">
<argument>%sulu_form.brevo_api_key%</argument>
</service>

<service id="sulu_form.dynamic.brevo_mail_template_select" class="Sulu\Bundle\FormBundle\Dynamic\Helper\BrevoMailTemplateSelect" public="true">
<argument>%sulu_form.brevo_api_key%</argument>
</service>
</services>
</container>
27 changes: 0 additions & 27 deletions Resources/config/type_sendinblue.xml

This file was deleted.

14 changes: 7 additions & 7 deletions Resources/doc/sendinblue.md → Resources/doc/brevo.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# Sendinblue Form Field
# Brevo Form Field

The following is showing an example how you can use the Sendinblue form field to add customers to your Sendinblue lists.
The following is showing an example how you can use the Brevo form field to add customers to your Brevo lists.

## Installation

First of all you need to install the sendinblue php sdk, otherwise the Sendinblue field type won't be available.
First of all you need to install the Brevo php sdk, otherwise the Brevo field type won't be available.

```json
{
"require": {
"sendinblue/api-v3-sdk": "^8.0"
"getbrevo/brevo-php": "^1.0"
}
}
```

or

```bash
composer require sendinblue/api-v3-sdk:"^8.0"
composer require getbrevo/brevo-php:"^1.0"
```

## Config
Expand All @@ -26,12 +26,12 @@ Add the following config to `config/packages/sulu_form.yaml`:

```yml
sulu_form:
sendinblue_api_key: "<YOUR_API_KEY>"
brevo_api_key: "<YOUR_API_KEY>"
```
It is recommended to store the api key as environment variable see [Symfony Docs](https://symfony.com/doc/4.4/configuration.html#configuration-environments).
## Why is there still no Sendinblue field type?
## Why is there still no Brevo field type?
1. Did you install the library?
2. Did you add an api key?
Expand Down
2 changes: 1 addition & 1 deletion Resources/doc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,6 @@ Make sure you've set the correct permissions in the Sulu backend for this bundle
## Additional form fields

- [Mailchimp](mailchimp.md "Mailchimp Form Field")
- [Sendinblue](sendinblue.md "Sendinblue Form Field")
- [Brevo](brevo.md "Brevo Form Field")
- [Recaptcha](recaptcha.md "Recaptcha Form Field")
- [Dropzone](dropzone.md "Dropzone Form Field")
12 changes: 6 additions & 6 deletions Resources/translations/admin.de.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"sulu_form.type.radiobuttons": "Radio Buttons",
"sulu_form.type.recaptcha": "Captcha",
"sulu_form.type.mailchimp": "Mailchimp",
"sulu_form.type.sendinblue": "Sendinblue",
"sulu_form.type.brevo": "Brevo",
"sulu_form.width.full": "Voll",
"sulu_form.width.half": "Halb",
"sulu_form.width.one_quarter": "Ein Viertel",
Expand All @@ -77,11 +77,11 @@
"sulu_form.width.one_sixth": "Ein Sechstel",
"sulu_form.width.five_sixths": "Fünf Sechstel",
"sulu_form.mailchimp_list": "Mailchimp Liste",
"sulu_form.sendinblue_list": "Sendinblue Liste",
"sulu_form.sendinblue_mail_template": "Sendinblue Mail Vorlage",
"sulu_form.sendinblue_redirection_url": "Weiterleitungs-URL",
"sulu_form.sendinblue_attribute_name_first_name": "Attribut-Name [Vorname]",
"sulu_form.sendinblue_attribute_name_last_name": "Attribut-Name [Nachname]",
"sulu_form.brevo_list": "Brevo Liste",
"sulu_form.brevo_mail_template": "Brevo Mail Vorlage",
"sulu_form.brevo_redirection_url": "Weiterleitungs-URL",
"sulu_form.brevo_attribute_name_first_name": "Attribut-Name [Vorname]",
"sulu_form.brevo_attribute_name_last_name": "Attribut-Name [Nachname]",
"sulu_form.salutation_ms": "Frau",
"sulu_form.salutation_mr": "Herr",
"sulu_form.salutation_neutral": "Neutral",
Expand Down
12 changes: 6 additions & 6 deletions Resources/translations/admin.en.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"sulu_form.type.radiobuttons": "Radio Buttons",
"sulu_form.type.recaptcha": "Captcha",
"sulu_form.type.mailchimp": "Mailchimp",
"sulu_form.type.sendinblue": "Sendinblue",
"sulu_form.type.brevo": "Brevo",
"sulu_form.width.full": "Full",
"sulu_form.width.half": "Half",
"sulu_form.width.one_quarter": "One quarter",
Expand All @@ -77,11 +77,11 @@
"sulu_form.width.one_sixth": "One sixth",
"sulu_form.width.five_sixths": "Five sixths",
"sulu_form.mailchimp_list": "Mailchimp List",
"sulu_form.sendinblue_list": "Sendinblue list",
"sulu_form.sendinblue_mail_template": "Sendinblue mail template",
"sulu_form.sendinblue_redirection_url": "Redirection url",
"sulu_form.sendinblue_attribute_name_first_name": "Attribute name [First name]",
"sulu_form.sendinblue_attribute_name_last_name": "Attribute name [Last name]",
"sulu_form.brevo_list": "Brevo list",
"sulu_form.brevo_mail_template": "Brevo mail template",
"sulu_form.brevo_redirection_url": "Redirection url",
"sulu_form.brevo_attribute_name_first_name": "Attribute name [First name]",
"sulu_form.brevo_attribute_name_last_name": "Attribute name [Last name]",
"sulu_form.salutation_ms": "Ms.",
"sulu_form.salutation_mr": "Mr.",
"sulu_form.salutation_neutral": "Neutral",
Expand Down
Loading

0 comments on commit a5ec05f

Please sign in to comment.