Skip to content

Commit 8ce6d45

Browse files
minor symfony#59365 [Notifier] reject invalid option types in the Brevo transport (xabbuh)
This PR was merged into the 7.3 branch. Discussion ---------- [Notifier] reject invalid option types in the Brevo transport | Q | A | ------------- | --- | Branch? | 7.3 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | | License | MIT Commits ------- 6c85dcd reject invalid option types in the Brevo transport
2 parents 16650e0 + 6c85dcd commit 8ce6d45

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

src/Symfony/Component/Notifier/Bridge/Brevo/BrevoOptions.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,16 @@ public function webUrl(string $url): static
4343
/**
4444
* @return $this
4545
*/
46-
public function type(string $type="transactional"): static
46+
public function type(string $type = 'transactional'): static
4747
{
4848
$this->options['type'] = $type;
4949

5050
return $this;
5151
}
5252

53+
/**
54+
* @return $this
55+
*/
5356
public function tag(string $tag): static
5457
{
5558
$this->options['tag'] = $tag;

src/Symfony/Component/Notifier/Bridge/Brevo/BrevoTransport.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Component\Notifier\Exception\TransportException;
1515
use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException;
16+
use Symfony\Component\Notifier\Exception\UnsupportedOptionsException;
1617
use Symfony\Component\Notifier\Message\MessageInterface;
1718
use Symfony\Component\Notifier\Message\SentMessage;
1819
use Symfony\Component\Notifier\Message\SmsMessage;
@@ -54,7 +55,13 @@ protected function doSend(MessageInterface $message): SentMessage
5455
}
5556

5657
$sender = $message->getFrom() ?: $this->sender;
57-
$options = $message->getOptions()?->toArray() ?? [];
58+
59+
if (($options = $message->getOptions()) && !$options instanceof BrevoOptions) {
60+
throw new UnsupportedOptionsException(__CLASS__, BrevoOptions::class, $options);
61+
}
62+
63+
$options = $options?->toArray() ?? [];
64+
5865
$body = [
5966
'sender' => $sender,
6067
'recipient' => $message->getPhone(),

src/Symfony/Component/Notifier/Bridge/Brevo/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
7.3
5+
---
6+
7+
* Add support for the `tag`, `type`, and `webUrl` options
8+
49
6.4
510
---
611

src/Symfony/Component/Notifier/Bridge/Brevo/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"require": {
1919
"php": ">=8.2",
2020
"symfony/http-client": "^6.4|^7.0",
21-
"symfony/notifier": "^7.2"
21+
"symfony/notifier": "^7.3"
2222
},
2323
"require-dev": {
2424
"symfony/event-dispatcher": "^5.4|^6.0|^7.0"

0 commit comments

Comments
 (0)