Skip to content

Commit 92d6fdb

Browse files
committed
Allow to set block_id for SlackActionsBlock and set url to nullable, allow setting value in SlackButtonBlockElement
1 parent 5276de0 commit 92d6fdb

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

src/Symfony/Component/Notifier/Bridge/Slack/Block/SlackActionsBlock.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,24 @@ public function __construct()
2424
/**
2525
* @return $this
2626
*/
27-
public function button(string $text, string $url, ?string $style = null): static
27+
public function button(string $text, ?string $url = null, ?string $style = null, ?string $value = null): static
2828
{
2929
if (25 === \count($this->options['elements'] ?? [])) {
3030
throw new \LogicException('Maximum number of buttons should not exceed 25.');
3131
}
3232

33-
$element = new SlackButtonBlockElement($text, $url, $style);
33+
$element = new SlackButtonBlockElement($text, $url, $style, $value);
3434

3535
$this->options['elements'][] = $element->toArray();
3636

3737
return $this;
3838
}
39+
40+
/**
41+
* @return $this
42+
*/
43+
public function id(string $id): static
44+
{
45+
$this->options['block_id'] = $id;
46+
}
3947
}

src/Symfony/Component/Notifier/Bridge/Slack/Block/SlackButtonBlockElement.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,27 @@
1616
*/
1717
final class SlackButtonBlockElement extends AbstractSlackBlockElement
1818
{
19-
public function __construct(string $text, string $url, ?string $style = null)
19+
public function __construct(string $text, ?string $url = null, ?string $style = null, ?string $value = null)
2020
{
2121
$this->options = [
2222
'type' => 'button',
2323
'text' => [
2424
'type' => 'plain_text',
2525
'text' => $text,
2626
],
27-
'url' => $url,
2827
];
2928

29+
if ($url) {
30+
$this->options['url'] = $url;
31+
}
32+
3033
if ($style) {
3134
// primary or danger
3235
$this->options['style'] = $style;
3336
}
37+
38+
if ($value) {
39+
$this->options['value'] = $value;
40+
}
3441
}
3542
}

0 commit comments

Comments
 (0)