10000 [Notifier][Mercure] Document options in README file by alamirault · Pull Request #60259 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Notifier][Mercure] Document options in README file #60259

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 7.4
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/Symfony/Component/Notifier/Bridge/Mercure/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,34 @@ where:
- `HUB_ID` is the Mercure hub id
- `TOPIC` is the topic IRI (optional, default: `https://symfony.com/notifier`. Could be either a single topic: `topic=https://foo` or multiple topics: `topic[]=/foo/1&topic[]=https://bar`)


Adding Options to a Chat Message
--------------------------------

With a Mercure Chat Message, you can use the `MercureOptions` class to add
message options.

```php
use Symfony\Component\Notifier\Message\ChatMessage;
use Symfony\Component\Notifier\Bridge\Mercure\MercureOptions;

$chatMessage = new ChatMessage('Contribute To Symfony');

$options = new MercureOptions(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that we decided to not use named arguments in Symfony Docs, could we please add a short comment to explain what does each option mean in this code example? Thanks!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's also because MercureOptions is diverging from the other option classes
the norm is to have a constructor with only array $options and to then have fluent setters, see existing classes for inspiration
it'd be nice to check all option classes and add some consistency - looks like it might be needed 🙏

['/topic/1', '/topic/2'],
true,
'id',
'type',
1,
['tag' => '1234', 'body' => 'TEST']
);

// Add the custom options to the chat message and send the message
$chatMessage->options($options);

$chatter->send($chatMessage);
```

Resources
---------

Expand Down
Loading
0