8000 feature #48616 [Notifier] GoogleChat CardsV1 is deprecated we must us… · symfony/symfony@8cc74f1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8cc74f1

Browse files
feature #48616 [Notifier] GoogleChat CardsV1 is deprecated we must use cardsV2 instead (daifma)
This PR was merged into the 6.3 branch. Discussion ---------- [Notifier] GoogleChat CardsV1 is deprecated we must use cardsV2 instead | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | no | New feature? | no | Deprecations? | yes | License | MIT Based on google developers api documentation. https://developers.google.com/chat/api/reference/rest/v1/cards-v1 CardsV1 is deprecated we must use cardsV2 instead. Commits ------- 86db505 CardsV1 is deprecated we must use cardsV2 instead.
2 parents ad892c1 + 86db505 commit 8cc74f1

File tree

3 files changed

+63
-0
lines changed

3 files changed

+63
-0
lines changed

src/Symfony/Component/Notifier/Bridge/GoogleChat/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
6.3
5+
---
6+
7+
* Deprecate `GoogleChatOptions::card()` in favor of `cardV2()`
8+
49
5.3
510
---
611

src/Symfony/Component/Notifier/Bridge/GoogleChat/GoogleChatOptions.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,29 @@ public function toArray(): array
6262
}
6363

6464
/**
65+
* @deprecated since Symfony 6.3, use "cardV2()" instead
66+
*
6567
* @return $this
6668
*/
6769
public function card(array $card): static
6870
{
71+
trigger_deprecation('symfony/google-chat-notifier', '6.3', '"%s()" is deprecated, use "cardV2()" instead.', __METHOD__);
72+
6973
$this->options['cards'][] = $card;
7074

7175
return $this;
7276
}
7377

78+
/**
79+
* @return $this
80+
*/
81+
public function cardV2(array $card): static
82+
{
83+
$this->options['cardsV2'][] = $card;
84+
85+
return $this;
86+
}
87+
7488
/**
7589
* @return $this
7690
*/

src/Symfony/Component/Notifier/Bridge/GoogleChat/Tests/GoogleChatOptionsTest.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616

1717
final class GoogleChatOptionsTest extends TestCase
1818
{
19+
/**
20+
* @group legacy
21+
*/
1922
public function testToArray()
2023
{
2124
$options = new GoogleChatOptions();
@@ -34,6 +37,47 @@ public function testToArray()
3437
$this->assertSame($expected, $options->toArray());
3538
}
3639

40+
public function testToArrayWithCardV2()
41+
{
42+
$options = new GoogleChatOptions();
43+
44+
$cardV2 = [
45+
'header' => [
46+
'title' => 'Sasha',
47+
'subtitle' => 'Software Engineer',
48+
'imageUrl' => 'https://developers.google.com/chat/images/quickstart-app-avatar.png',
49+
'imageType' => 'CIRCLE',
50+
'imageAltText' => 'Avatar for Sasha',
51+
],
52+
'sections' => [
53+
[
54+
'header' => 'Contact Info',
55+
'collapsible' => true,
56+
'widgets' => [
57+
'decoratedText' => [
58+
'startIcon' => ['knownIcon' => 'EMAIL'],
59+
'text' => 'sasha@example.com',
60+
],
61+
],
62+
],
63+
],
64+
];
65+
66+
$options
67+
->text('Hello Bot')
68+
->cardV2($cardV2)
69+
;
70+
71+
$expected = [
72+
'text' => 'Hello Bot',
73+
'cardsV2' => [
74+
$cardV2,
75+
],
76+
];
77+
78+
$this->assertSame($expected, $options->toArray());
79+
}
80+
3781
public function testOptionsWithThread()
3882
{
3983
$thread = 'fgh.ijk';

0 commit comments

Comments
 (0)
0