@@ -348,7 +348,7 @@ To send a notification, autowire the
348348
349349 use Symfony\Component\Notifier\Notification\Notification;
350350 use Symfony\Component\Notifier\NotifierInterface;
351- use Symfony\Component\Notifier\Recipient\AdminRecipient ;
351+ use Symfony\Component\Notifier\Recipient\Recipient ;
352352
353353 class InvoiceController extends AbstractController
354354 {
@@ -365,7 +365,7 @@ To send a notification, autowire the
365365 ->content('You got a new invoice for 15 EUR.');
366366
367367 // The receiver of the Notification
368- $recipient = new AdminRecipient (
368+ $recipient = new Recipient (
369369 $user->getEmail(),
370370 $user->getPhonenumber()
371371 );
@@ -385,22 +385,23 @@ both an email and sms notification to the user.
385385The default notification also has a ``content() `` and ``emoji() `` method to
386386set the notification content and icon.
387387
388- Symfony provides three types of recipients:
388+ Symfony provides the following recipients:
389389
390390:class: `Symfony\\ Component\\ Notifier\\ Recipient\\ NoRecipient `
391391 This is the default and is useful when there is no need to have
392392 information about the receiver. For example, the browser channel uses
393393 the current requests's :ref: `session flashbag <flash-messages >`;
394394
395395:class: `Symfony\\ Component\\ Notifier\\ Recipient\\ Recipient `
396- This contains only the email address of the user and can be used for
397- messages on the email and browser channel;
398-
399- :class: `Symfony\\ Component\\ Notifier\\ Recipient\\ AdminRecipient `
400396 This can contain both email address and phonenumber of the user. This
401397 recipient can be used for all channels (depending on whether they are
402398 actually set).
403399
400+ .. versionadded :: 5.2
401+
402+ The ``AdminRecipient `` class was removed in Symfony 5.2, you should use
403+ ``Recipient `` instead.
404+
404405Configuring Channel Policies
405406~~~~~~~~~~~~~~~~~~~~~~~~~~~~
406407
@@ -515,7 +516,8 @@ very high and the recipient has a phone number::
515516 namespace App\Notifier;
516517
517518 use Symfony\Component\Notifier\Notification\Notification;
518- use Symfony\Component\Notifier\Recipient\Recipient;
519+ use Symfony\Component\Notifier\Recipient\RecipientInterface;
520+ use Symfony\Component\Notifier\Recipient\SmsRecipientInterface;
519521
520522 class InvoiceNotification extends Notification
521523 {
@@ -526,12 +528,11 @@ very high and the recipient has a phone number::
526528 $this->price = $price;
527529 }
528530
529- public function getChannels(Recipient $recipient)
531+ public function getChannels(RecipientInterface $recipient)
530532 {
531533 if (
532534 $this->price > 10000
533- && $recipient instanceof AdminRecipient
534- && null !== $recipient->getPhone()
535+ && $recipient instanceof SmsRecipientInterface
535536 ) {
536537 return ['sms'];
537538 }
@@ -555,7 +556,7 @@ and its ``asChatMessage()`` method::
555556 use Symfony\Component\Notifier\Message\ChatMessage;
556557 use Symfony\Component\Notifier\Notification\ChatNotificationInterface;
557558 use Symfony\Component\Notifier\Notification\Notification;
558- use Symfony\Component\Notifier\Recipient\Recipient ;
559+ use Symfony\Component\Notifier\Recipient\SmsRecipientInterface ;
559560
560561 class InvoiceNotification extends Notification implements ChatNotificationInterface
561562 {
@@ -566,7 +567,7 @@ and its ``asChatMessage()`` method::
566567 $this->price = $price;
567568 }
568569
569- public function asChatMessage(Recipient $recipient, string $transport = null): ?ChatMessage
570+ public function asChatMessage(RecipientInterface $recipient, string $transport = null): ?ChatMessage
570571 {
571572 // Add a custom emoji if the message is sent to Slack
572573 if ('slack' === $transport) {
0 commit comments