Skip to content

Commit 6e63db7

Browse files
committed
feature #48503 [Notifier] Add options to SmsMessage (gnito-org)
This PR was merged into the 6.3 branch. Discussion ---------- [Notifier] Add options to `SmsMessage` | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | no | New feature? | yes | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | | License | MIT | Doc PR | Add the ability to attach optional options to an SMS message, which can then be processed by the notifier bridge. Some SMS APIs allow dynamic options that can be set on a per message basis, which cannot be satisfied by options in the DSN. Commits ------- be77a1f [Notifier] Add options to SmsMessage
2 parents f35572f + be77a1f commit 6e63db7

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/Symfony/Component/Notifier/Message/SmsMessage.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ class SmsMessage implements MessageInterface
2424
private string $subject;
2525
private string $phone;
2626
private string $from;
27+
private ?MessageOptionsInterface $options;
2728

28-
public function __construct(string $phone, string $subject, string $from = '')
29+
public function __construct(string $phone, string $subject, string $from = '', MessageOptionsInterface $options = null)
2930
{
3031
if ('' === $phone) {
3132
throw new InvalidArgumentException(sprintf('"%s" needs a phone number, it cannot be empty.', __CLASS__));
@@ -34,6 +35,7 @@ public function __construct(string $phone, string $subject, string $from = '')
3435
$this->subject = $subject;
3536
$this->phone = $phone;
3637
$this->from = $from;
38+
$this->options = $options;
3739
}
3840

3941
public static function fromNotification(Notification $notification, SmsRecipientInterface $recipient): self
@@ -110,8 +112,18 @@ public function getFrom(): string
110112
return $this->from;
111113
}
112114

115+
/**
116+
* @return $this
117+
*/
118+
public function options(MessageOptionsInterface $options): static
119+
{
120+
$this->options = $options;
121+
122+
return $this;
123+
}
124+
113125
public function getOptions(): ?MessageOptionsInterface
114126
{
115-
return null;
127+
return $this->options;
116128
}
117129
}

0 commit comments

Comments
 (0)