Skip to content

Commit

Permalink
Enlarge README.md for Novu. Refs: #50414
Browse files Browse the repository at this point in the history
  • Loading branch information
wouter-toppy committed Jun 15, 2023
1 parent 05c57e2 commit 24e1136
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions src/Symfony/Component/Notifier/Bridge/Novu/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,60 @@ DSN example
NOVU_DSN=novu://API_KEY@default
```

Notification example
--------------------

```php
class NovuNotification extends Notification implements PushNotificationInterface
{
public function asPushMessage(
NovuSubscriberRecipient|RecipientInterface $recipient,
?string $transport = null,
): ?PushMessage {
return new PushMessage(
$this->getSubject(),
$this->getContent(),
new NovuOptions(
$recipient->getSubscriberId(),
$recipient->getFirstName(),
$recipient->getLastName(),
$recipient->getEmail(),
$recipient->getPhone(),
$recipient->getAvatar(),
$recipient->getLocale(),
[],
),
);
}
}
```

```php
$notification = new NovuNotification;
$notification->subject('test');
$notification->channels(['push']);
$notification->content(
json_encode(
[
'param1' => 'Lorum Ipsum',
]
)
);

$this->notifier->send(
$notification,
new NovuSubscriberRecipient(
"123",
'Wouter',
'van der Loop',
'woutervdl@toppy.nl',
null,
null,
null,
),
);
```

Resources
---------

Expand Down

0 comments on commit 24e1136

Please sign in to comment.