File tree 19 files changed +70
-28
lines changed
Filter options
src/Symfony/Component/Notifier 19 files changed +70
-28
lines changed
Original file line number Diff line number Diff line change 13
13
14
14
use Symfony \Component \Notifier \Exception \LogicException ;
15
15
use Symfony \Component \Notifier \Exception \TransportException ;
16
+ use Symfony \Component \Notifier \Exception \UnsupportedMessageTypeException ;
16
17
use Symfony \Component \Notifier \Message \ChatMessage ;
17
18
use Symfony \Component \Notifier \Message \MessageInterface ;
18
19
use Symfony \Component \Notifier \Message \SentMessage ;
@@ -59,7 +60,7 @@ public function supports(MessageInterface $message): bool
59
60
protected function doSend (MessageInterface $ message ): SentMessage
60
61
{
61
62
if (!$ message instanceof ChatMessage) {
62
- throw new LogicException ( sprintf ( ' The "%s" transport only supports instances of "%s" (instance of "%s" given). ' , __CLASS__ , ChatMessage::class, get_debug_type ( $ message)) );
63
+ throw new UnsupportedMessageTypeException ( __CLASS__ , ChatMessage::class, $ message );
63
64
}
64
65
65
66
$ messageOptions = $ message ->getOptions ();
Original file line number Diff line number Diff line change 13
13
14
14
use Symfony \Component \HttpClient \Exception \JsonException ;
15
15
use Symfony \Component \HttpClient \Exception \TransportException as HttpClientTransportException ;
16
- use Symfony \Component \Notifier \Exception \LogicException ;
17
16
use Symfony \Component \Notifier \Exception \TransportException ;
17
+ use Symfony \Component \Notifier \Exception \UnsupportedMessageTypeException ;
18
18
use Symfony \Component \Notifier \Message \MessageInterface ;
19
19
use Symfony \Component \Notifier \Message \SentMessage ;
20
20
use Symfony \Component \Notifier \Message \SmsMessage ;
@@ -55,7 +55,7 @@ public function supports(MessageInterface $message): bool
55
55
protected function doSend (MessageInterface $ message ): SentMessage
56
56
{
57
57
if (!$ message instanceof SmsMessage) {
58
- throw new LogicException ( sprintf ( ' The "%s" transport only supports instances of "%s" (instance of "%s" given). ' , __CLASS__ , SmsMessage::class, get_debug_type ( $ message)) );
58
+ throw new UnsupportedMessageTypeException ( __CLASS__ , SmsMessage::class, $ message );
59
59
}
60
60
61
61
$ messageData = [
Original file line number Diff line number Diff line change 12
12
namespace Symfony \Component \Notifier \Bridge \Firebase ;
13
13
14
14
use Symfony \Component \Notifier \Exception \InvalidArgumentException ;
15
- use Symfony \Component \Notifier \Exception \LogicException ;
16
15
use Symfony \Component \Notifier \Exception \TransportException ;
16
+ use Symfony \Component \Notifier \Exception \UnsupportedMessageTypeException ;
17
17
use Symfony \Component \Notifier \Message \ChatMessage ;
18
18
use Symfony \Component \Notifier \Message \MessageInterface ;
19
19
use Symfony \Component \Notifier \Message \SentMessage ;
@@ -54,7 +54,7 @@ public function supports(MessageInterface $message): bool
54
54
protected function doSend (MessageInterface $ message ): SentMessage
55
55
{
56
56
if (!$ message instanceof ChatMessage) {
57
- throw new LogicException ( sprintf ( ' The "%s" transport only supports instances of "%s" (instance of "%s" given). ' , __CLASS__ , ChatMessage::class, get_debug_type ( $ message)) );
57
+ throw new UnsupportedMessageTypeException ( __CLASS__ , ChatMessage::class, $ message );
58
58
}
59
59
60
60
$ endpoint = sprintf ('https://%s ' , $ this ->getEndpoint ());
Original file line number Diff line number Diff line change 14
14
use Symfony \Component \HttpClient \Exception \JsonException ;
15
15
use Symfony \Component \Notifier \Exception \LogicException ;
16
16
use Symfony \Component \Notifier \Exception \TransportException ;
17
+ use Symfony \Component \Notifier \Exception \UnsupportedMessageTypeException ;
17
18
use Symfony \Component \Notifier \Message \ChatMessage ;
18
19
use Symfony \Component \Notifier \Message \MessageInterface ;
19
20
use Symfony \Component \Notifier \Message \SentMessage ;
@@ -89,7 +90,7 @@ public function supports(MessageInterface $message): bool
89
90
protected function doSend (MessageInterface $ message ): SentMessage
90
91
{
91
92
if (!$ message instanceof ChatMessage) {
92
- throw new LogicException ( sprintf ( ' The "%s" transport only supports instances of "%s" (instance of "%s" given). ' , __CLASS__ , ChatMessage::class, \get_class ( $ message)) );
93
+ throw new UnsupportedMessageTypeException ( __CLASS__ , ChatMessage::class, $ message );
93
94
}
94
95
if ($ message ->getOptions () && !$ message ->getOptions () instanceof GoogleChatOptions) {
95
96
throw new LogicException (sprintf ('The "%s" transport only supports instances of "%s" for options. ' , __CLASS__ , GoogleChatOptions::class));
Original file line number Diff line number Diff line change 11
11
12
12
namespace Symfony \Component \Notifier \Bridge \Infobip ;
13
13
14
- use Symfony \Component \Notifier \Exception \LogicException ;
15
14
use Symfony \Component \Notifier \Exception \TransportException ;
15
+ use Symfony \Component \Notifier \Exception \UnsupportedMessageTypeException ;
16
16
use Symfony \Component \Notifier \Message \MessageInterface ;
17
17
use Symfony \Component \Notifier \Message \SentMessage ;
18
18
use Symfony \Component \Notifier \Message \SmsMessage ;
@@ -52,7 +52,7 @@ public function supports(MessageInterface $message): bool
52
52
protected function doSend (MessageInterface $ message ): SentMessage
53
53
{
54
54
if (!$ message instanceof SmsMessage) {
55
- throw new LogicException ( sprintf ( ' The "%s" transport only supports instances of "%s" (instance of "%s" given). ' , __CLASS__ , SmsMessage::class, get_debug_type ( $ message)) );
55
+ throw new UnsupportedMessageTypeException ( __CLASS__ , SmsMessage::class, $ message );
56
56
}
57
57
58
58
$ endpoint = sprintf ('https://%s/sms/2/text/advanced ' , $ this ->getEndpoint ());
Original file line number Diff line number Diff line change 14
14
use Symfony \Component \Notifier \Bridge \LinkedIn \Share \AuthorShare ;
15
15
use Symfony \Component \Notifier \Exception \LogicException ;
16
16
use Symfony \Component \Notifier \Exception \TransportException ;
17
+ use Symfony \Component \Notifier \Exception \UnsupportedMessageTypeException ;
17
18
use Symfony \Component \Notifier \Message \ChatMessage ;
18
19
use Symfony \Component \Notifier \Message \MessageInterface ;
19
20
use Symfony \Component \Notifier \Message \SentMessage ;
@@ -61,7 +62,7 @@ public function supports(MessageInterface $message): bool
61
62
protected function doSend (MessageInterface $ message ): SentMessage
62
63
{
63
64
if (!$ message instanceof ChatMessage) {
64
- throw new LogicException ( sprintf ( ' The "%s" transport only supports instances of "%s" (instance of "%s" given). ' , __CLASS__ , ChatMessage::class, \get_class ( $ message)) );
65
+ throw new UnsupportedMessageTypeException ( __CLASS__ , ChatMessage::class, $ message );
65
66
}
66
67
if ($ message ->getOptions () && !$ message ->getOptions () instanceof LinkedInOptions) {
67
68
throw new LogicException (sprintf ('The "%s" transport only supports instances of "%s" for options. ' , __CLASS__ , LinkedInOptions::class));
Original file line number Diff line number Diff line change 11
11
12
12
namespace Symfony \Component \Notifier \Bridge \Mattermost ;
13
13
14
- use Symfony \Component \Notifier \Exception \LogicException ;
15
14
use Symfony \Component \Notifier \Exception \TransportException ;
15
+ use Symfony \Component \Notifier \Exception \UnsupportedMessageTypeException ;
16
16
use Symfony \Component \Notifier \Message \ChatMessage ;
17
17
use Symfony \Component \Notifier \Message \MessageInterface ;
18
18
use Symfony \Component \Notifier \Message \SentMessage ;
@@ -54,7 +54,7 @@ public function supports(MessageInterface $message): bool
54
54
protected function doSend (MessageInterface $ message ): SentMessage
55
55
{
56
56
if (!$ message instanceof ChatMessage) {
57
- throw new LogicException ( sprintf ( ' The "%s" transport only supports instances of "%s" (instance of "%s" given). ' , __CLASS__ , ChatMessage::class, get_debug_type ( $ message)) );
57
+ throw new UnsupportedMessageTypeException ( __CLASS__ , ChatMessage::class, $ message );
58
58
}
59
59
60
60
$ endpoint = sprintf ('https://%s/api/v4/posts ' , $ this ->getEndpoint ());
Original file line number Diff line number Diff line change 13
13
14
14
use Symfony \Component \Notifier \Exception \LogicException ;
15
15
use Symfony \Component \Notifier \Exception \TransportException ;
16
+ use Symfony \Component \Notifier \Exception \UnsupportedMessageTypeException ;
16
17
use Symfony \Component \Notifier \Message \MessageInterface ;
17
18
use Symfony \Component \Notifier \Message \SentMessage ;
18
19
use Symfony \Component \Notifier \Message \SmsMessage ;
@@ -57,7 +58,7 @@ public function supports(MessageInterface $message): bool
57
58
protected function doSend (MessageInterface $ message ): SentMessage
58
59
{
59
60
if (!$ message instanceof SmsMessage) {
60
- throw new LogicException ( sprintf ( ' The "%s" transport only supports instances of "%s" (instance of "%s" given). ' , __CLASS__ , SmsMessage::class, \get_class ( $ message)) );
61
+ throw new UnsupportedMessageTypeException ( __CLASS__ , SmsMessage::class, $ message );
61
62
}
62
63
63
64
if ($ message ->getOptions () && !$ message ->getOptions () instanceof MobytOptions) {
Original file line number Diff line number Diff line change 11
11
12
12
namespace Symfony \Component \Notifier \Bridge \Nexmo ;
13
13
14
- use Symfony \Component \Notifier \Exception \LogicException ;
15
14
use Symfony \Component \Notifier \Exception \TransportException ;
15
+ use Symfony \Component \Notifier \Exception \UnsupportedMessageTypeException ;
16
16
use Symfony \Component \Notifier \Message \MessageInterface ;
17
17
use Symfony \Component \Notifier \Message \SentMessage ;
18
18
use Symfony \Component \Notifier \Message \SmsMessage ;
@@ -55,7 +55,7 @@ public function supports(MessageInterface $message): bool
55
55
protected function doSend (MessageInterface $ message ): SentMessage
56
56
{
57
57
if (!$ message instanceof SmsMessage) {
58
- throw new LogicException ( sprintf ( ' The "%s" transport only supports instances of "%s" (instance of "%s" given). ' , __CLASS__ , SmsMessage::class, get_debug_type ( $ message)) );
58
+ throw new UnsupportedMessageTypeException ( __CLASS__ , SmsMessage::class, $ message );
59
59
}
60
60
61
61
$ response = $ this ->client ->request ('POST ' , 'https:// ' .$ this ->getEndpoint ().'/sms/json ' , [
Original file line number Diff line number Diff line change 11
11
12
12
namespace Symfony \Component \Notifier \Bridge \OvhCloud ;
13
13
14
- use Symfony \Component \Notifier \Exception \LogicException ;
15
14
use Symfony \Component \Notifier \Exception \TransportException ;
15
+ use Symfony \Component \Notifier \Exception \UnsupportedMessageTypeException ;
16
16
use Symfony \Component \Notifier \Message \MessageInterface ;
17
17
use Symfony \Component \Notifier \Message \SentMessage ;
18
18
use Symfony \Component \Notifier \Message \SmsMessage ;
@@ -57,7 +57,7 @@ public function supports(MessageInterface $message): bool
57
57
protected function doSend (MessageInterface $ message ): SentMessage
58
58
{
59
59
if (!$ message instanceof SmsMessage) {
60
- throw new LogicException ( sprintf ( ' The "%s" transport only supports instances of "%s" (instance of "%s" given). ' , __CLASS__ , SmsMessage::class, get_debug_type ( $ message)) );
60
+ throw new UnsupportedMessageTypeException ( __CLASS__ , SmsMessage::class, $ message );
61
61
}
62
62
63
63
$ endpoint = sprintf ('https://%s/1.0/sms/%s/jobs ' , $ this ->getEndpoint (), $ this ->serviceName );
Original file line number Diff line number Diff line change 13
13
14
14
use Symfony \Component \Notifier \Exception \LogicException ;
15
15
use Symfony \Component \Notifier \Exception \TransportException ;
16
+ use Symfony \Component \Notifier \Exception \UnsupportedMessageTypeException ;
16
17
use Symfony \Component \Notifier \Message \ChatMessage ;
17
18
use Symfony \Component \Notifier \Message \MessageInterface ;
18
19
use Symfony \Component \Notifier \Message \SentMessage ;
@@ -59,7 +60,7 @@ public function supports(MessageInterface $message): bool
59
60
protected function doSend (MessageInterface $ message ): SentMessage
60
61
{
61
62
if (!$ message instanceof ChatMessage) {
62
- throw new LogicException ( sprintf ( ' The "%s" transport only supports instances of "%s" (instance of "%s" given). ' , __CLASS__ , ChatMessage::class, get_debug_type ( $ message)) );
63
+ throw new UnsupportedMessageTypeException ( __CLASS__ , ChatMessage::class, $ message );
63
64
}
64
65
if ($ message ->getOptions () && !$ message ->getOptions () instanceof RocketChatOptions) {
65
66
throw new LogicException (sprintf ('The "%s" transport only supports instances of "%s" for options. ' , __CLASS__ , RocketChatOptions::class));
Original file line number Diff line number Diff line change 11
11
12
12
namespace Symfony \Component \Notifier \Bridge \Sendinblue ;
13
13
14
- use Symfony \Component \Notifier \Exception \LogicException ;
15
14
use Symfony \Component \Notifier \Exception \TransportException ;
15
+ use Symfony \Component \Notifier \Exception \UnsupportedMessageTypeException ;
16
16
use Symfony \Component \Notifier \Message \MessageInterface ;
17
17
use Symfony \Component \Notifier \Message \SentMessage ;
18
18
use Symfony \Component \Notifier \Message \SmsMessage ;
@@ -53,7 +53,7 @@ public function supports(MessageInterface $message): bool
53
53
protected function doSend (MessageInterface $ message ): SentMessage
54
54
{
55
55
if (!$ message instanceof SmsMessage) {
56
- throw new LogicException ( sprintf ( ' The "%s" transport only supports instances of "%s" (instance of "%s" given). ' , __CLASS__ , SmsMessage::class, get_debug_type ( $ message)) );
56
+ throw new UnsupportedMessageTypeException ( __CLASS__ , SmsMessage::class, $ message );
57
57
}
58
58
59
59
$ response = $ this ->client ->request ('POST ' , 'https:// ' .$ this ->getEndpoint ().'/v3/transactionalSMS/sms ' , [
Original file line number Diff line number Diff line change 11
11
12
12
namespace Symfony \Component \Notifier \Bridge \Sinch ;
13
13
14
- use Symfony \Component \Notifier \Exception \LogicException ;
15
14
use Symfony \Component \Notifier \Exception \TransportException ;
15
+ use Symfony \Component \Notifier \Exception \UnsupportedMessageTypeException ;
16
16
use Symfony \Component \Notifier \Message \MessageInterface ;
17
17
use Symfony \Component \Notifier \Message \SentMessage ;
18
18
use Symfony \Component \Notifier \Message \SmsMessage ;
@@ -55,7 +55,7 @@ public function supports(MessageInterface $message): bool
55
55
protected function doSend (MessageInterface $ message ): SentMessage
56
56
{
57
57
if (!$ message instanceof SmsMessage) {
58
- throw new LogicException ( sprintf ( ' The "%s" transport only supports instances of "%s" (instance of "%s" given). ' , __CLASS__ , SmsMessage::class, get_debug_type ( $ message)) );
58
+ throw new UnsupportedMessageTypeException ( __CLASS__ , SmsMessage::class, $ message );
59
59
}
60
60
61
61
$ endpoint = sprintf ('https://%s/xms/v1/%s/batches ' , $ this ->getEndpoint (), $ this ->accountSid );
Original file line number Diff line number Diff line change 13
13
14
14
use Symfony \Component \Notifier \Exception \LogicException ;
15
15
use Symfony \Component \Notifier \Exception \TransportException ;
16
+ use Symfony \Component \Notifier \Exception \UnsupportedMessageTypeException ;
16
17
use Symfony \Component \Notifier \Message \ChatMessage ;
17
18
use Symfony \Component \Notifier \Message \MessageInterface ;
18
19
use Symfony \Component \Notifier \Message \SentMessage ;
@@ -59,7 +60,7 @@ public function supports(MessageInterface $message): bool
59
60
protected function doSend (MessageInterface $ message ): SentMessage
60
61
{
61
62
if (!$ message instanceof ChatMessage) {
62
- throw new LogicException ( sprintf ( ' The "%s" transport only supports instances of "%s" (instance of "%s" given). ' , __CLASS__ , ChatMessage::class, get_debug_type ( $ message)) );
63
+ throw new UnsupportedMessageTypeException ( __CLASS__ , ChatMessage::class, $ message );
63
64
}
64
65
if ($ message ->getOptions () && !$ message ->getOptions () instanceof SlackOptions) {
65
66
throw new LogicException (sprintf ('The "%s" transport only supports instances of "%s" for options. ' , __CLASS__ , SlackOptions::class));
Original file line number Diff line number Diff line change 11
11
12
12
namespace Symfony \Component \Notifier \Bridge \Smsapi ;
13
13
14
- use Symfony \Component \Notifier \Exception \LogicException ;
15
14
use Symfony \Component \Notifier \Exception \TransportException ;
15
+ use Symfony \Component \Notifier \Exception \UnsupportedMessageTypeException ;
16
16
use Symfony \Component \Notifier \Message \MessageInterface ;
17
17
use Symfony \Component \Notifier \Message \SentMessage ;
18
18
use Symfony \Component \Notifier \Message \SmsMessage ;
@@ -52,7 +52,7 @@ public function supports(MessageInterface $message): bool
52
52
protected function doSend (MessageInterface $ message ): SentMessage
53
53
{
54
54
if (!$ message instanceof SmsMessage) {
55
- throw new LogicException ( sprintf ( ' The "%s" transport only supports instances of "%s" (instance of "%s" given). ' , __CLASS__ , SmsMessage::class, get_debug_type ( $ message)) );
55
+ throw new UnsupportedMessageTypeException ( __CLASS__ , SmsMessage::class, $ message );
56
56
}
57
57
58
58
$ endpoint = sprintf ('https://%s/sms.do ' , $ this ->getEndpoint ());
Original file line number Diff line number Diff line change 13
13
14
14
use Symfony \Component \Notifier \Exception \LogicException ;
15
15
use Symfony \Component \Notifier \Exception \TransportException ;
16
+ use Symfony \Component \Notifier \Exception \UnsupportedMessageTypeException ;
16
17
use Symfony \Component \Notifier \Message \ChatMessage ;
17
18
use Symfony \Component \Notifier \Message \MessageInterface ;
18
19
use Symfony \Component \Notifier \Message \SentMessage ;
@@ -64,7 +65,7 @@ public function supports(MessageInterface $message): bool
64
65
protected function doSend (MessageInterface $ message ): SentMessage
65
66
{
66
67
if (!$ message instanceof ChatMessage) {
67
- throw new LogicException ( sprintf ( ' The "%s" transport only supports instances of "%s" (instance of "%s" given). ' , __CLASS__ , ChatMessage::class, get_debug_type ( $ message)) );
68
+ throw new UnsupportedMessageTypeException ( __CLASS__ , ChatMessage::class, $ message );
68
69
}
69
70
70
71
if ($ message ->getOptions () && !$ message ->getOptions () instanceof TelegramOptions) {
Original file line number Diff line number Diff line change 11
11
12
12
namespace Symfony \Component \Notifier \Bridge \Twilio ;
13
13
14
- use Symfony \Component \Notifier \Exception \LogicException ;
15
14
use Symfony \Component \Notifier \Exception \TransportException ;
15
+ use Symfony \Component \Notifier \Exception \UnsupportedMessageTypeException ;
16
16
use Symfony \Component \Notifier \Message \MessageInterface ;
17
17
use Symfony \Component \Notifier \Message \SentMessage ;
18
18
use Symfony \Component \Notifier \Message \SmsMessage ;
@@ -55,7 +55,7 @@ public function supports(MessageInterface $message): bool
55
55
protected function doSend (MessageInterface $ message ): SentMessage
56
56
{
57
57
if (!$ message instanceof SmsMessage) {
58
- throw new LogicException ( sprintf ( ' The "%s" transport only supports instances of "%s" (instance of "%s" given). ' , __CLASS__ , SmsMessage::class, get_debug_type ( $ message)) );
58
+ throw new UnsupportedMessageTypeException ( __CLASS__ , SmsMessage::class, $ message );
59
59
}
60
60
61
61
$ endpoint = sprintf ('https://%s/2010-04-01/Accounts/%s/Messages.json ' , $ this ->getEndpoint (), $ this ->accountSid );
Original file line number Diff line number Diff line change 13
13
14
14
use Symfony \Component \Notifier \Exception \LogicException ;
15
15
use Symfony \Component \Notifier \Exception \TransportException ;
16
+ use Symfony \Component \Notifier \Exception \UnsupportedMessageTypeException ;
16
17
use Symfony \Component \Notifier \Message \ChatMessage ;
17
18
use Symfony \Component \Notifier \Message \MessageInterface ;
18
19
use Symfony \Component \Notifier \Message \SentMessage ;
@@ -56,7 +57,7 @@ public function supports(MessageInterface $message): bool
56
57
protected function doSend (MessageInterface $ message ): SentMessage
57
58
{
58
59
if (!$ message instanceof ChatMessage) {
59
- throw new LogicException ( sprintf ( ' The "%s" transport only supports instances of "%s" (instance of "%s" given). ' , __CLASS__ , ChatMessage::class, get_debug_type ( $ message)) );
60
+ throw new UnsupportedMessageTypeException ( __CLASS__ , ChatMessage::class, $ message );
60
61
}
61
62
62
63
if (null !== $ message ->getOptions () && !($ message ->getOptions () instanceof ZulipOptions)) {
Original file line number Diff line number Diff line change
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 \Exception ;
13
+
14
+ use Symfony \Component \Notifier \Message \MessageInterface ;
15
+
16
+ /**
17
+ * @author Oskar Stark <oskarstark@googlemail.com>
18
+ *
19
+ * @experimental in 5.3
20
+ */
21
+ class UnsupportedMessageTypeException extends LogicException
22
+ {
23
+ public function __construct (string $ transport , string $ supported , MessageInterface $ given )
24
+ {
25
+ $ message = sprintf (
26
+ 'The "%s" transport only supports instances of "%s" (instance of "%s" given). ' ,
27
+ \get_class ($ transport ),
28
+ $ supported ,
29
+ get_debug_type ($ given )
30
+ );
31
+
32
+ parent ::__construct ($ message );
33
+ }
34
+ }
You can’t perform that action at this time.
0 commit comments