From 1a52e8717f875f7d0ed558b91ed95ead472cb6c8 Mon Sep 17 00:00:00 2001 From: Christophe VERGNE Date: Fri, 31 May 2024 16:49:52 +0200 Subject: [PATCH] [Notifier] [Slack] Add README examples about button block element and emoji/verbatim options to section block --- .../Component/Notifier/Bridge/Slack/README.md | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/src/Symfony/Component/Notifier/Bridge/Slack/README.md b/src/Symfony/Component/Notifier/Bridge/Slack/README.md index 121e6a7edfde7..5e260b534e910 100644 --- a/src/Symfony/Component/Notifier/Bridge/Slack/README.md +++ b/src/Symfony/Component/Notifier/Bridge/Slack/README.md @@ -74,6 +74,46 @@ $chatMessage->options($slackOptions); $chatter->send($chatMessage); ``` +Alternatively, a single button can be added to a section using the `accessory()` method and the `SlackButtonBlockElement` class. + +```php +use Symfony\Component\Notifier\Bridge\Slack\Block\SlackButtonBlockElement; +use Symfony\Component\Notifier\Bridge\Slack\Block\SlackDividerBlock; +use Symfony\Component\Notifier\Bridge\Slack\Block\SlackSectionBlock; +use Symfony\Component\Notifier\Bridge\Slack\SlackOptions; +use Symfony\Component\Notifier\Message\ChatMessage; + +$chatMessage = new ChatMessage('Contribute To Symfony'); + +$slackOptions = (new SlackOptions()) + ->block((new SlackSectionBlock()) + ->text('Symfony Framework') + ->accessory( + new SlackButtonBlockElement( + 'Report bugs', + 'https://symfony.com/doc/current/contributing/code/bugs.html', + 'danger' + ) + ) + ) + ->block(new SlackDividerBlock()) + ->block((new SlackSectionBlock()) + ->text('Symfony Documentation') + ->accessory( + new SlackButtonBlockElement( + 'Improve Documentation', + 'https://symfony.com/doc/current/contributing/documentation/standards.html', + 'primary' + ) + ) + ); + +// Add the custom options to the chat message and send the message +$chatMessage->options($slackOptions); + +$chatter->send($chatMessage); +``` + Adding Fields and Values to a Message ------------------------------------- @@ -104,6 +144,34 @@ $chatMessage->options($options); $chatter->send($chatMessage); ``` +Define text objects properties +------------------------------ + +[Text objects properties](https://api.slack.com/reference/block-kit/composition-objects#text) can be set on any `text()` or `field()` method : + +```php +use Symfony\Component\Notifier\Bridge\Slack\Block\SlackSectionBlock; +use Symfony\Component\Notifier\Bridge\Slack\SlackOptions; +use Symfony\Component\Notifier\Message\ChatMessage; + +$chatMessage = new ChatMessage('Slack Notifier'); + +$options = (new SlackOptions()) + ->block( + (new SlackSectionBlock()) + ->field('My **Markdown** content with clickable URL : symfony.com') // Markdown content (default) + ->field('*Plain text content*', markdown: false) // Plain text content + ->field('Not clickable URL : symfony.com', verbatim: true) // Only for markdown content + ->field('Thumbs up emoji code is :thumbsup: ', emoji: false) // Only for plain text content + ); + +// Add the custom options to the chat message and send the message +$chatMessage->options($options); + +$chatter->send($chatMessage); +``` + + Adding a Header to a Message ---------------------------- pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy