@@ -74,6 +74,46 @@ $chatMessage->options($slackOptions);
74
74
$chatter->send($chatMessage);
75
75
```
76
76
77
+ Alternatively, a single button can be added to a section using the ` accessory() ` method and the ` SlackButtonBlockElement ` class.
78
+
79
+ ``` php
80
+ use Symfony\Component\Notifier\Bridge\Slack\Block\SlackButtonBlockElement;
81
+ use Symfony\Component\Notifier\Bridge\Slack\Block\SlackDividerBlock;
82
+ use Symfony\Component\Notifier\Bridge\Slack\Block\SlackSectionBlock;
83
+ use Symfony\Component\Notifier\Bridge\Slack\SlackOptions;
84
+ use Symfony\Component\Notifier\Message\ChatMessage;
85
+
86
+ $chatMessage = new ChatMessage('Contribute To Symfony');
87
+
88
+ $slackOptions = (new SlackOptions())
89
+ ->block((new SlackSectionBlock())
90
+ ->text('Symfony Framework')
91
+ ->accessory(
92
+ new SlackButtonBlockElement(
93
+ 'Report bugs',
94
+ 'https://symfony.com/doc/current/contributing/code/bugs.html',
95
+ 'danger'
96
+ )
97
+ )
98
+ )
99
+ ->block(new SlackDividerBlock())
100
+ ->block((new SlackSectionBlock())
101
+ ->text('Symfony Documentation')
102
+ ->accessory(
103
+ new SlackButtonBlockElement(
104
+ 'Improve Documentation',
105
+ 'https://symfony.com/doc/current/contributing/documentation/standards.html',
106
+ 'primary'
107
+ )
108
+ )
109
+ );
110
+
111
+ // Add the custom options to the chat message and send the message
112
+ $chatMessage->options($slackOptions);
113
+
114
+ $chatter->send($chatMessage);
115
+ ```
116
+
77
117
Adding Fields and Values to a Message
78
118
-------------------------------------
79
119
@@ -104,6 +144,34 @@ $chatMessage->options($options);
104
144
$chatter->send($chatMessage);
105
145
```
106
146
147
+ Define text objects properties
148
+ ------------------------------
149
+
150
+ [ Text objects properties] ( https://api.slack.com/reference/block-kit/composition-objects#text ) can be set on any ` text() ` or ` field() ` method :
151
+
152
+ ``` php
153
+ use Symfony\Component\Notifier\Bridge\Slack\Block\SlackSectionBlock;
154
+ use Symfony\Component\Notifier\Bridge\Slack\SlackOptions;
155
+ use Symfony\Component\Notifier\Message\ChatMessage;
156
+
157
+ $chatMessage = new ChatMessage('Slack Notifier');
158
+
159
+ $options = (new SlackOptions())
160
+ ->block(
161
+ (new SlackSectionBlock())
162
+ ->field('My **Markdown** content with clickable URL : symfony.com') // Markdown content (default)
163
+ ->field('*Plain text content*', markdown: false) // Plain text content
164
+ ->field('Not clickable URL : symfony.com', verbatim: true) // Only for markdown content
165
+ ->field('Thumbs up emoji code is :thumbsup: ', emoji: false) // Only for plain text content
166
+ );
167
+
168
+ // Add the custom options to the chat message and send the message
169
+ $chatMessage->options($options);
170
+
171
+ $chatter->send($chatMessage);
172
+ ```
173
+
174
+
107
175
Adding a Header to a Message
108
176
----------------------------
109
177
0 commit comments