From 0014e28d4a1be25e7671d93650fb2b84ba12d0f2 Mon Sep 17 00:00:00 2001 From: Savvas Alexandrou Date: Mon, 20 Jan 2020 17:28:26 +0100 Subject: [PATCH 1/2] Slack notifier actions documentation --- components/notifier.rst | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/components/notifier.rst b/components/notifier.rst index 9e7be5c4197..8fd39c87961 100644 --- a/components/notifier.rst +++ b/components/notifier.rst @@ -26,3 +26,44 @@ Usage We're still working on the docs of this component. Check this page again in a few days. + +Slack Actions Block for Slack Message +------------------------------------- + +With a Slack Message you can add some interactive options called `Block elements`_:: + + use Symfony\Component\Notifier\Bridge\Slack\Block\SlackActionsBlock; + use Symfony\Component\Notifier\Bridge\Slack\SlackOptions; + use Symfony\Component\Notifier\Message\ChatMessage; + use Symfony\Component\Notifier\Chatter; + use Symfony\Component\Notifier\Bridge\Slack\SlackTransport; + + // Initialize a chatter with Slack Transport + $chatter = new Chatter(new SlackTransport('token')); + + // Create a message + $chatMessage = (new ChatMessage()) + ->subject('Contribute To Symfony'); + + // Create Slack Actions Block and add some buttons + $contributeToSymfonyBlocks = (new SlackActionsBlock()) + ->button( + 'Improve Documentation', + 'https://symfony.com/doc/current/contributing/documentation/standards.html', + 'primary' + ) + ->button( + 'Report bugs', + 'https://symfony.com/doc/current/contributing/code/bugs.html', + 'danger' + ); + $contributeToSymfonyOptions = (new SlackOptions())->block($contributeToSymfonyBlocks); + + // Add the Buttons as Options to the Message + $chatMessage->options($contributeToSymfonyOptions); + + // And then send the Message + $chatter->send($chatMessage); + + +.. _`Block elements`: https://api.slack.com/reference/block-kit/block-elements From ea5b55f2f65a55849426a5d2e973dc0a2616c634 Mon Sep 17 00:00:00 2001 From: Savvas Alexandrou Date: Mon, 20 Jan 2020 17:50:23 +0100 Subject: [PATCH 2/2] Reorder the use statements alphabetically --- components/notifier.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/notifier.rst b/components/notifier.rst index 8fd39c87961..fdb0c585e28 100644 --- a/components/notifier.rst +++ b/components/notifier.rst @@ -34,9 +34,9 @@ With a Slack Message you can add some interactive options called `Block elements use Symfony\Component\Notifier\Bridge\Slack\Block\SlackActionsBlock; use Symfony\Component\Notifier\Bridge\Slack\SlackOptions; - use Symfony\Component\Notifier\Message\ChatMessage; - use Symfony\Component\Notifier\Chatter; use Symfony\Component\Notifier\Bridge\Slack\SlackTransport; + use Symfony\Component\Notifier\Chatter; + use Symfony\Component\Notifier\Message\ChatMessage; // Initialize a chatter with Slack Transport $chatter = new Chatter(new SlackTransport('token'));