8000 Enlarge README.md for Novu. Refs: symfony#50414 · symfony/symfony@24e1136 · GitHub
[go: up one dir, main page]

Skip to content

Commit 24e1136

Browse files
committed
Enlarge README.md for Novu. Refs: #50414
1 parent 05c57e2 commit 24e1136

File tree

1 file changed

+54
-0
lines changed
  • src/Symfony/Component/Notifier/Bridge/Novu

1 file changed

+54
-0
lines changed

src/Symfony/Component/Notifier/Bridge/Novu/README.md

+54
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,60 @@ DSN example
1010
NOVU_DSN=novu://API_KEY@default
1111
```
1212

13+
Notification example
14+
--------------------
15+
16+
```php
17+
class NovuNotification extends Notification implements PushNotificationInterface
18+
{
19+
public function asPushMessage(
20+
NovuSubscriberRecipient|RecipientInterface $recipient,
21+
?string $transport = null,
22+
): ?PushMessage {
23+
return new PushMessage(
24+
$this->getSubject(),
25+
$this->getContent(),
26+
new NovuOptions(
27+
$recipient->getSubscriberId(),
28+
$recipient->getFirstName(),
29+
$recipient->getLastName(),
30+
$recipient->getEmail(),
31+
$recipient->getPhone(),
32+
$recipient->getAvatar(),
33+
$recipient->getLocale(),
34+
[],
35+
),
36+
);
37+
}
38+
}
39+
```
40+
41+
```php
42+
$notification = new NovuNotification;
43+
$notification->subject('test');
44+
$notification->channels(['push']);
45+
$notification->content(
46+
json_encode(
47+
[
48+
'param1' => 'Lorum Ipsum',
49+
]
50+
)
51+
);
52+
53+
$this->notifier->send(
54+
$notification,
55+
new NovuSubscriberRecipient(
56+
"123",
57+
'Wouter',
58+
'van der Loop',
59+
'woutervdl@toppy.nl',
60+
null,
61+
null,
62+
null,
63+
),
64+
);
65+
```
66+
1367
Resources
1468
---------
1569

0 commit comments

Comments
 (0)
0