Skip to content

Commit 6207c46

Browse files
committed
Closes #14653 by documenting the SlackContextBlock class
1 parent 07ff0d8 commit 6207c46

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed
15.7 KB
Loading

notifier/chatters.rst

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ The result will be something like:
131131
.. image:: /_images/notifier/slack/field-method.png
132132
:align: center
133133

134-
.. versionadded:: 5.3
134+
.. versionadded:: 5.1
135135

136136
The `field()` method was introduced in Symfony 5.1.
137137

@@ -175,6 +175,49 @@ The result will be something like:
175175

176176
The `SlackHeaderBlock` class was introduced in Symfony 5.3.
177177

178+
Adding a footer to a Slack Message
179+
-------------------------------------------
180+
181+
To add a footer to your message you can use the
182+
:class:`Symfony\\Component\\Notifier\\Bridge\\Slack\\Block\\SlackContextBlock` class::
183+
184+
use Symfony\Component\Notifier\Bridge\Slack\Block\SlackContextBlock;
185+
use Symfony\Component\Notifier\Bridge\Slack\Block\SlackDividerBlock;
186+
use Symfony\Component\Notifier\Bridge\Slack\Block\SlackSectionBlock;
187+
use Symfony\Component\Notifier\Bridge\Slack\SlackOptions;
188+
use Symfony\Component\Notifier\Message\ChatMessage;
189+
190+
$chatMessage = new ChatMessage('Symfony Feature');
191+
192+
$contextBlock = (new SlackContextBlock())
193+
->text('My Context')
194+
->image('https://symfony.com/logos/symfony_white_03.png', 'Symfony Logo')
195+
;
196+
197+
$options = (new SlackOptions())
198+
->block((new SlackSectionBlock())->text('My message'))
199+
->block(new SlackDividerBlock())
200+
->block(
201+
(new SlackSectionBlock())
202+
->field('*Max Rating*')
203+
->field('5.0')
204+
->field('*Min Rating*')
205+
->field('1.0')
206+
)
207+
->block($contextBlock)
208+
;
209+
210+
$chatter->send($chatMessage);
211+
212+
The result will be something like:
213+
214+
.. image:: /_images/notifier/slack/slack-footer.png
215+
:align: center
216+
217+
.. versionadded:: 5.3
218+
219+
The `SlackContextBlock` class was introduced in Symfony 5.3.
220+
178221
Sending a Slack Message as a reply
179222
-------------------------------------------
180223

0 commit comments

Comments
 (0)