feature #35167 [Notifier] Remove superfluous parameters in *Message::fromNotification() (fancyweb)

This PR was merged into the 5.1-dev branch.

Discussion
----------

[Notifier] Remove superfluous parameters in *Message::fromNotification()

| Q             | A
| ------------- | ---
| Branch?       | 5.0
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

Those classes are final so I think we don't need those extra arguments.

Commits
-------

d0dacf51e1 [Notifier] Remove superfluous parameters in *Message::fromNotification()
This commit is contained in:
Fabien Potencier 2020-02-04 14:11:37 +01:00
commit c8725bf198
9 changed files with 23 additions and 9 deletions

View File

@ -37,6 +37,14 @@ Messenger
* Deprecated RedisExt transport. It has moved to a separate package. Run `composer require symfony/redis-messenger` to use the new classes.
* Deprecated use of invalid options in Redis and AMQP connections.
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
-------

View File

@ -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([

View File

@ -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"

View File

@ -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
-----

View File

@ -36,7 +36,7 @@ class ChatChannel extends AbstractChannel
}
if (null === $message) {
$message = ChatMessage::fromNotification($notification, $recipient, $transportName);
$message = ChatMessage::fromNotification($notification);
}
$message->transport($transportName);

View File

@ -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) {

View File

@ -12,7 +12,6 @@
namespace Symfony\Component\Notifier\Message;
use Symfony\Component\Notifier\Notification\Notification;
use Symfony\Component\Notifier\Recipient\Recipient;
/**
* @author Fabien Potencier <fabien@symfony.com>
@ -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;

View File

@ -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())

View File

@ -34,7 +34,7 @@ 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));