Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1791f01

Browse files
ikeribfabpot
authored andcommitted
[Notifier] [Brevo][SMS] Brevo sms notifier add options
1 parentf73be8a commit1791f01

File tree

2 files changed

+75
-5
lines changed

2 files changed

+75
-5
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespaceSymfony\Component\Notifier\Bridge\Brevo;
13+
14+
useSymfony\Component\Notifier\Message\MessageOptionsInterface;
15+
16+
finalclass BrevoOptionsimplements MessageOptionsInterface
17+
{
18+
publicfunction__construct(
19+
privatearray$options = [],
20+
) {
21+
}
22+
23+
publicfunctiontoArray():array
24+
{
25+
return$this->options;
26+
}
27+
28+
publicfunctiongetRecipientId(): ?string
29+
{
30+
returnnull;
31+
}
32+
33+
/**
34+
* @return $this
35+
*/
36+
publicfunctionwebUrl(string$url):static
37+
{
38+
$this->options['webUrl'] =$url;
39+
40+
return$this;
41+
}
42+
43+
/**
44+
* @return $this
45+
*/
46+
publicfunctiontype(string$type="transactional"):static
47+
{
48+
$this->options['type'] =$type;
49+
50+
return$this;
51+
}
52+
53+
publicfunctiontag(string$tag):static
54+
{
55+
$this->options['tag'] =$tag;
56+
57+
return$this;
58+
}
59+
}

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

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,24 @@ protected function doSend(MessageInterface $message): SentMessage
5454
}
5555

5656
$sender =$message->getFrom() ?:$this->sender;
57+
$options =$message->getOptions()?->toArray() ?? [];
58+
$body = [
59+
'sender' =>$sender,
60+
'recipient' =>$message->getPhone(),
61+
'content' =>$message->getSubject(),
62+
];
63+
if (isset($options['webUrl'])) {
64+
$body['webUrl'] =$options['webUrl'];
65+
}
66+
if (isset($options['type'])) {
67+
$body['type'] =$options['type'];
68+
}
69+
if (isset($options['tag'])) {
70+
$body['tag'] =$options['tag'];
71+
}
5772

5873
$response =$this->client->request('POST','https://'.$this->getEndpoint().'/v3/transactionalSMS/sms', [
59-
'json' => [
60-
'sender' =>$sender,
61-
'recipient' =>$message->getPhone(),
62-
'content' =>$message->getSubject(),
63-
],
74+
'json' =>$body,
6475
'headers' => [
6576
'api-key' =>$this->apiKey,
6677
],

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp