From d0dacf51e12613c0f2e7059781d3d06b281055cf Mon Sep 17 00:00:00 2001 From: Thomas Calvet Date: Thu, 2 Jan 2020 11:02:56 +0100 Subject: [PATCH] [Notifier] Remove superfluous parameters in *Message::fromNotification() --- UPGRADE-5.1.md | 8 ++++++++ .../Notifier/Bridge/Slack/Tests/SlackTransportTest.php | 3 +-- src/Symfony/Component/Notifier/Bridge/Slack/composer.json | 2 +- src/Symfony/Component/Notifier/CHANGELOG.md | 8 ++++++++ src/Symfony/Component/Notifier/Channel/ChatChannel.php | 2 +- src/Symfony/Component/Notifier/Channel/SmsChannel.php | 2 +- src/Symfony/Component/Notifier/Message/ChatMessage.php | 3 +-- src/Symfony/Component/Notifier/Message/EmailMessage.php | 2 +- src/Symfony/Component/Notifier/Message/SmsMessage.php | 4 ++-- 9 files changed, 24 insertions(+), 10 deletions(-) diff --git a/UPGRADE-5.1.md b/UPGRADE-5.1.md index afa2f217ef..165a334e91 100644 --- a/UPGRADE-5.1.md +++ b/UPGRADE-5.1.md @@ -18,6 +18,14 @@ HttpFoundation `RedirectResponse::create()`, and `StreamedResponse::create()` methods (use `__construct()` instead) +Notifier +-------- + + * [BC BREAK] The `ChatMessage::fromNotification()` method's `$recipient` and `$transport` + arguments were removed. + * [BC BREAK] The `EmailMessage::fromNotification()` and `SmsMessage::fromNotification()` + methods' `$transport` argument was removed. + Routing ------- diff --git a/src/Symfony/Component/Notifier/Bridge/Slack/Tests/SlackTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Slack/Tests/SlackTransportTest.php index cbfaadd606..9e7dbdfc9c 100644 --- a/src/Symfony/Component/Notifier/Bridge/Slack/Tests/SlackTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Slack/Tests/SlackTransportTest.php @@ -21,7 +21,6 @@ use Symfony\Component\Notifier\Message\ChatMessage; use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\MessageOptionsInterface; use Symfony\Component\Notifier\Notification\Notification; -use Symfony\Component\Notifier\Recipient\Recipient; use Symfony\Contracts\HttpClient\HttpClientInterface; use Symfony\Contracts\HttpClient\ResponseInterface; @@ -145,7 +144,7 @@ final class SlackTransportTest extends TestCase ->willReturn(json_encode(['ok' => true])); $notification = new Notification($message); - $chatMessage = ChatMessage::fromNotification($notification, new Recipient('test-email@example.com')); + $chatMessage = ChatMessage::fromNotification($notification); $options = SlackOptions::fromNotification($notification); $expectedBody = http_build_query([ diff --git a/src/Symfony/Component/Notifier/Bridge/Slack/composer.json b/src/Symfony/Component/Notifier/Bridge/Slack/composer.json index 7f04e9d24f..cb05a44657 100644 --- a/src/Symfony/Component/Notifier/Bridge/Slack/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/Slack/composer.json @@ -18,7 +18,7 @@ "require": { "php": "^7.2.5", "symfony/http-client": "^4.3|^5.0", - "symfony/notifier": "^5.0" + "symfony/notifier": "^5.1" }, "require-dev": { "symfony/event-dispatcher": "^4.3|^5.0" diff --git a/src/Symfony/Component/Notifier/CHANGELOG.md b/src/Symfony/Component/Notifier/CHANGELOG.md index e2dde962bc..ce86089d2f 100644 --- a/src/Symfony/Component/Notifier/CHANGELOG.md +++ b/src/Symfony/Component/Notifier/CHANGELOG.md @@ -1,6 +1,14 @@ CHANGELOG ========= +5.1.0 +----- + +* [BC BREAK] The `ChatMessage::fromNotification()` method's `$recipient` and `$transport` + arguments were removed. +* [BC BREAK] The `EmailMessage::fromNotification()` and `SmsMessage::fromNotification()` + methods' `$transport` argument was removed. + 5.0.0 ----- diff --git a/src/Symfony/Component/Notifier/Channel/ChatChannel.php b/src/Symfony/Component/Notifier/Channel/ChatChannel.php index 7531bf3fee..f8859cdaf4 100644 --- a/src/Symfony/Component/Notifier/Channel/ChatChannel.php +++ b/src/Symfony/Component/Notifier/Channel/ChatChannel.php @@ -36,7 +36,7 @@ class ChatChannel extends AbstractChannel } if (null === $message) { - $message = ChatMessage::fromNotification($notification, $recipient, $transportName); + $message = ChatMessage::fromNotification($notification); } $message->transport($transportName); diff --git a/src/Symfony/Component/Notifier/Channel/SmsChannel.php b/src/Symfony/Component/Notifier/Channel/SmsChannel.php index 08e813705b..53d3f0cc54 100644 --- a/src/Symfony/Component/Notifier/Channel/SmsChannel.php +++ b/src/Symfony/Component/Notifier/Channel/SmsChannel.php @@ -32,7 +32,7 @@ class SmsChannel extends AbstractChannel } if (null === $message) { - $message = SmsMessage::fromNotification($notification, $recipient, $transportName); + $message = SmsMessage::fromNotification($notification, $recipient); } if (null !== $transportName) { diff --git a/src/Symfony/Component/Notifier/Message/ChatMessage.php b/src/Symfony/Component/Notifier/Message/ChatMessage.php index 73b60ec495..d6004d0071 100644 --- a/src/Symfony/Component/Notifier/Message/ChatMessage.php +++ b/src/Symfony/Component/Notifier/Message/ChatMessage.php @@ -12,7 +12,6 @@ namespace Symfony\Component\Notifier\Message; use Symfony\Component\Notifier\Notification\Notification; -use Symfony\Component\Notifier\Recipient\Recipient; /** * @author Fabien Potencier @@ -32,7 +31,7 @@ final class ChatMessage implements MessageInterface $this->options = $options; } - public static function fromNotification(Notification $notification, Recipient $recipient, string $transport = null): self + public static function fromNotification(Notification $notification): self { $message = new self($notification->getSubject()); $message->notification = $notification; diff --git a/src/Symfony/Component/Notifier/Message/EmailMessage.php b/src/Symfony/Component/Notifier/Message/EmailMessage.php index 6baaa5b7c1..54d846bfd1 100644 --- a/src/Symfony/Component/Notifier/Message/EmailMessage.php +++ b/src/Symfony/Component/Notifier/Message/EmailMessage.php @@ -35,7 +35,7 @@ final class EmailMessage implements MessageInterface $this->envelope = $envelope; } - public static function fromNotification(Notification $notification, Recipient $recipient, string $transport = null): self + public static function fromNotification(Notification $notification, Recipient $recipient): self { if (!class_exists(NotificationEmail::class)) { $email = (new Email()) diff --git a/src/Symfony/Component/Notifier/Message/SmsMessage.php b/src/Symfony/Component/Notifier/Message/SmsMessage.php index e704e169a9..5a35761869 100644 --- a/src/Symfony/Component/Notifier/Message/SmsMessage.php +++ b/src/Symfony/Component/Notifier/Message/SmsMessage.php @@ -34,10 +34,10 @@ final class SmsMessage implements MessageInterface $this->phone = $phone; } - public static function fromNotification(Notification $notification, Recipient $recipient, string $transport = null): self + public static function fromNotification(Notification $notification, Recipient $recipient): self { if (!$recipient instanceof SmsRecipientInterface) { - throw new LogicException(sprintf('To send a SMS message, "%s" should implement "%s" or the recipient should implement "%s".', get_class($notification), SmsNotificationInterface::class, SmsRecipientInterface::class)); + throw new LogicException(sprintf('To send a SMS message, "%s" should implement "%s" or the recipient should implement "%s".', \get_class($notification), SmsNotificationInterface::class, SmsRecipientInterface::class)); } return new self($recipient->getPhone(), $notification->getSubject());