-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Notifier] Add SMS options to MessageMedia notifier #48586
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
src/Symfony/Component/Notifier/Bridge/MessageMedia/CHANGELOG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
CHANGELOG | ||
========= | ||
|
||
6.3 | ||
--- | ||
|
||
* Add `MessageMediaOptions` class | ||
|
||
6.2 | ||
--- | ||
|
||
|
157 changes: 157 additions & 0 deletions
157
src/Symfony/Component/Notifier/Bridge/MessageMedia/MessageMediaOptions.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Notifier\Bridge\MessageMedia; | ||
|
||
use Symfony\Component\Notifier\Message\MessageOptionsInterface; | ||
|
||
/** | ||
* @author gnito-org <https://github.com/gnito-org> | ||
*/ | ||
final class MessageMediaOptions implements MessageOptionsInterface | ||
{ | ||
private array $options; | ||
|
||
public function __construct(array $options = []) | ||
{ | ||
$this->options = $options; | ||
} | ||
|
||
public function getCallbackUrl(): ?string | ||
{ | ||
return $this->options['callback_url'] ?? null; | ||
} | ||
|
||
public function getDeliveryReport(): ?bool | ||
{ | ||
return $this->options['delivery_report'] ?? null; | ||
} | ||
|
||
public function getFormat(): ?string | ||
{ | ||
return $this->options['format'] ?? null; | ||
} | ||
|
||
public function getFrom(): ?string | ||
{ | ||
return $this->options['from'] ?? null; | ||
} | ||
|
||
public function getMedia(): ?array | ||
{ | ||
return $this->options['media'] ?? null; | ||
} | ||
|
||
public function getMessageExpiryTimestamp(): ?int | ||
{ | ||
return $this->options['message_expiry_timestamp'] ?? null; | ||
} | ||
|
||
public function getMetadata(): ?array | ||
{ | ||
return $this->options['metadata'] ?? null; | ||
} | ||
|
||
public function getRecipientId(): ?string | ||
{ | ||
return $this->options['recipient_id'] ?? null; | ||
} | ||
|
||
public function getScheduled(): ?string | ||
{ | ||
return $this->options['scheduled'] ?? null; | ||
} | ||
|
||
public function getSubject(): ?string | ||
{ | ||
return $this->options['subject'] ?? null; | ||
} | ||
|
||
public function setCallbackUrl(string $callbackUrl): self | ||
{ | ||
$this->options['callback_url'] = $callbackUrl; | ||
|
||
return $this; | ||
} | ||
|
||
public function setDeliveryReport(bool $deliveryReport): self | ||
{ | ||
$this->options['delivery_report'] = $deliveryReport; | ||
|
||
return $this; | ||
} | ||
|
||
public function setFormat(string $format): self | ||
{ | ||
$this->options['format'] = $format; | ||
|
||
return $this; | ||
} | ||
|
||
public function setFrom(string $from): self | ||
{ | ||
$this->options['from'] = $from; | ||
|
||
return $this; | ||
} | ||
|
||
public function setMedia(array $media): self | ||
{ | ||
$this->options['media'] = $media; | ||
|
||
return $this; | ||
} | ||
|
||
public function setMessageExpiryTimestamp(int $messageExpiryTimestamp): self | ||
{ | ||
$this->options['message_expiry_timestamp'] = $messageExpiryTimestamp; | ||
|
||
return $this; | ||
} | ||
|
||
public function setMetadata(array $metadata): self | ||
{ | ||
$this->options['metadata'] = $metadata; | ||
|
||
return $this; | ||
} | ||
|
||
public function setRecipientId(string $id): self | ||
{ | ||
$this->options['recipient_id'] = $id; | ||
|
||
return $this; | ||
} | ||
|
||
public function setScheduled(string $scheduled): self | ||
{ | ||
$this->options['scheduled'] = $scheduled; | ||
|
||
return $this; | ||
} | ||
|
||
public function setSubject(string $subject): self | ||
{ | ||
$this->options['subject'] = $subject; | ||
|
||
return $this; | ||
} | ||
|
||
public function toArray(): array | ||
{ | ||
$options = $this->options; | ||
if (isset($options['recipient_id'])) { | ||
unset($options['recipient_id']); | ||
} | ||
|
||
return $options; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/Symfony/Component/Notifier/Bridge/MessageMedia/Tests/MessageMediaOptionsTest.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Notifier\Bridge\MessageMedia\Tests; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\Notifier\Bridge\MessageMedia\MessageMediaOptions; | ||
|
||
class MessageMediaOptionsTest extends TestCase | ||
{ | ||
public function testMessageMediaOptions() | ||
{ | ||
$messageMediaOptions = (new MessageMediaOptions())->setFrom('test_from')->setMedia(['test_media'])->setCallbackUrl('test_callback_url')->setFormat('test_format')->setRecipientId('test_recipient')->setDeliveryReport(true)->setMessageExpiryTimestamp(999)->setMetadata(['test_metadata'])->setScheduled('test_scheduled')->setSubject('test_subject'); | ||
|
||
self::assertSame([ | ||
'from' => 'test_from', | ||
'media' => ['test_media'], | ||
'callback_url' => 'test_callback_url', | ||
'format' => 'test_format', | ||
'delivery_report' => true, | ||
'message_expiry_timestamp' => 999, | ||
'metadata' => ['test_metadata'], | ||
'scheduled' => 'test_scheduled', | ||
'subject' => 'test_subject', | ||
], $messageMediaOptions->toArray()); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we remove all getters? I don't think it's worth exposing them. toArray() works fine for the purpose.
Can you consider this for all your PRs please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing all the getters is inconsistent with the MessageOptionsInterface.