8000 [Notifier] Add notifier for Teams · symfony/symfony@4a59f17 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4a59f17

Browse files
committed
[Notifier] Add notifier for Teams
1 parent dc0d45d commit 4a59f17

36 files changed

+1540
-0
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@
117117
use Symfony\Component\Notifier\Bridge\Sinch\SinchTransportFactory;
118118
use Symfony\Component\Notifier\Bridge\Slack\SlackTransportFactory;
119119
use Symfony\Component\Notifier\Bridge\Smsapi\SmsapiTransportFactory;
120+
use Symfony\Component\Notifier\Bridge\Teams\TeamsTransportFactory;
120121
use Symfony\Component\Notifier\Bridge\Telegram\TelegramTransportFactory;
121122
use Symfony\Component\Notifier\Bridge\Twilio\TwilioTransportFactory;
122123
use Symfony\Component\Notifier\Bridge\Zulip\ZulipTransportFactory;
@@ -2227,6 +2228,7 @@ private function registerNotifierConfiguration(array $config, ContainerBuilder $
22272228
SendinblueNotifierTransportFactory::class => 'notifier.transport_factory.sendinblue',
22282229
DiscordTransportFactory::class => 'notifier.transport_factory.discord',
22292230
LinkedInTransportFactory::class => 'notifier.transport_factory.linkedin',
2231+
TeamsTransportFactory::class => 'notifier.transport_factory.teams',
22302232
];
22312233

22322234
foreach ($classToServices as $class => $service) {

src/Symfony/Bundle/FrameworkBundle/Resources/config/notifier_transports.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
use Symfony\Component\Notifier\Bridge\Sinch\SinchTransportFactory;
2828
use Symfony\Component\Notifier\Bridge\Slack\SlackTransportFactory;
2929
use Symfony\Component\Notifier\Bridge\Smsapi\SmsapiTransportFactory;
30+
use Symfony\Component\Notifier\Bridge\Teams\TeamsTransportFactory;
3031
use Symfony\Component\Notifier\Bridge\Telegram\TelegramTransportFactory;
3132
use Symfony\Component\Notifier\Bridge\Twilio\TwilioTransportFactory;
3233
use Symfony\Component\Notifier\Bridge\Zulip\ZulipTransportFactory;
@@ -115,6 +116,10 @@
115116
->parent('notifier.transport_factory.abstract')
116117
->tag('chatter.transport_factory')
117118

119+
->set('notifier.transport_factory.teams', TeamsTransportFactory::class)
120+
->parent('notifier.transport_factory.abstract')
121+
->tag('chatter.transport_factory')
122+
118123
->set('notifier.transport_factory.null', NullTransportFactory::class)
119124
->parent('notifier.transport_factory.abstract')
120125
->tag('chatter.transport_factory')
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/Tests export-ignore
2+
/phpunit.xml.dist export-ignore
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Notifier\Bridge\Teams\Action;
13+
14+
/**
15+
* @author Edouard Lescot <edouard.lescot@gmail.com>
16+
*/
17+
abstract class AbstractTeamsAction implements TeamsActionInterface
18+
{
19+
protected $options = [];
20+
21+
public function toArray(): array
22+
{
23+
return $this->options;
24+
}
25+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Notifier\Bridge\Teams\Action;
13+
14+
/**
15+
* @author Edouard Lescot <edouard.lescot@gmail.com>
16+
*/
17+
abstract class AbstractTeamsActionElement implements TeamsActionElementInterface
18+
{
19+
protected $options = [];
20+
21+
public function toArray(): array
22+
{
23+
return $this->options;
24+
}
25+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Notifier\Bridge\Teams\Action;
13+
14+
/**
15+
* @author Edouard Lescot <edouard.lescot@gmail.com>
16+
*/
17+
abstract class AbstractTeamsActionInput implements TeamsActionInterface
18+
{
19+
protected $options = [];
20+
21+
/**
22+
* @return $this
23+
*/
24+
public function id(string $id): self
25+
{
26+
$this->options['id'] = $id;
27+
28+
return $this;
29+
}
30+
31+
/**
32+
* @return $this
33+
*/
34+
public function isRequired(bool $required): self
35+
{
36+
$this->options['isRequired'] = $required;
37+
38+
return $this;
39+
}
40+
41+
/**
42+
* @return $this
43+
*/
44+
public function title(string $title): self
45+
{
46+
$this->options['title'] = $title;
47+
48+
return $this;
49+
}
50+
51+
/**
52+
* @return $this
53+
*/
54+
public function value(string $value): self
55+
{
56+
$this->options['value'] = $value;
57+
58+
return $this;
59+
}
60+
61+
public function toArray(): array
62+
{
63+
return $this->options;
64+
}
65+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Notifier\Bridge\Teams\Action;
13+
14+
use Symfony\Component\Notifier\Exception\LogicException;
15+
16+
/**
17+
* @author Edouard Lescot <edouard.lescot@gmail.com>
18+
*
19+
* @see https://docs.microsoft.com/fr-fr/outlook/actionable-messages/message-card-reference#actioncard-action
20+
*/
21+
class TeamsActionCardAction extends AbstractTeamsAction
22+
{
23+
/**
24+
* @return $this
25+
*/
26+
public function name(string $name): self
27+
{
28+
$this->options['name'] = $name;
29+
30+
return $this;
31+
}
32+
33+
/**
34+
* @return $this
35+
*/
36+
public function input(TeamsActionInputInterface $inputAction): self
37+
{
38+
$this->options['inputs'][] = $inputAction->toArray();
39+
40+
return $this;
41+
}
42+
43+
/**
44+
* @return $this
45+
*/
46+
public function action(TeamsActionInterface $action): self
47+
{
48+
if (!\in_array(\get_class($action), [TeamsHttpPostAction::class, TeamsOpenUriAction::class])) {
49+
throw new LogicException(sprintf('"%s" must be an instance of "%s" or "%s".', \get_class($action), TeamsHttpPostAction::class, TeamsOpenUriAction::class));
50+
}
51+
52+
$this->options['actions'][] = $action->toArray();
53+
54+
return $this;
55+
}
56+
57+
public function toArray(): array
58+
{
59+
$this->options['@type'] = 'ActionCard';
60+
61+
return parent::toArray();
62+
}
63+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3 3CA1 +
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Notifier\Bridge\Teams\Action;
13+
14+
/**
15+
* @author Edouard Lescot <edouard.lescot@gmail.com>
16+
*/
17+
interface TeamsActionElementInterface
18+
{
19+
public function toArray(): array;
20+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Notifier\Bridge\Teams\Action;
13+
14+
/**
15+
* @author Edouard Lescot <edouard.lescot@gmail.com>
16+
*/
17+
interface TeamsActionInputInterface
18+
{
19+
public function toArray(): array;
20+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Notifier\Bridge\Teams\Action;
13+
14+
/**
15+
* @author Edouard Lescot <edouard.lescot@gmail.com>
16+
*/
17+
interface TeamsActionInterface
18+
{
19+
public function toArray(): array;
20+
}

0 commit comments

Comments
 (0)
0