From 8dd9d9393f9b205fa43ff3180f74cc4fae655dee Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 30 May 2023 14:42:45 +0200 Subject: [PATCH] [Notifier] Fix ContactEveryoneOptions --- .../ContactEveryoneOptions.php | 26 ++++++++++++++++++- .../ContactEveryoneTransport.php | 4 ++- .../Tests/ContactEveryoneOptionsTest.php | 2 +- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Notifier/Bridge/ContactEveryone/ContactEveryoneOptions.php b/src/Symfony/Component/Notifier/Bridge/ContactEveryone/ContactEveryoneOptions.php index 122cb93680f48..ca264d8018eae 100644 --- a/src/Symfony/Component/Notifier/Bridge/ContactEveryone/ContactEveryoneOptions.php +++ b/src/Symfony/Component/Notifier/Bridge/ContactEveryone/ContactEveryoneOptions.php @@ -15,6 +15,8 @@ /** * @author gnito-org + * + * @see https://ceo-be.multimediabs.com/attachments/hosted/lightApiManualsFR */ final class ContactEveryoneOptions implements MessageOptionsInterface { @@ -35,7 +37,7 @@ public function getRecipientId(): ?string */ public function diffusionName(string $diffusionName): static { - $this->options['diffusion_name'] = $diffusionName; + $this->options['diffusionname'] = $diffusionName; return $this; } @@ -50,6 +52,28 @@ public function category(string $category): static return $this; } + /** + * @param 'fr_FR'|'en_GB' $locale + * + * @return $this + */ + public function locale(string $locale): static + { + $this->options['locale'] = $locale; + + return $this; + } + + /** + * @return $this + */ + public function unicode(bool $unicode): static + { + $this->options['xcharset'] = $unicode ? 'true' : 'false'; + + return $this; + } + public function toArray(): array { return $this->options; diff --git a/src/Symfony/Component/Notifier/Bridge/ContactEveryone/ContactEveryoneTransport.php b/src/Symfony/Component/Notifier/Bridge/ContactEveryone/ContactEveryoneTransport.php index 0f09f1e54cde6..f9d2e6c2dfe66 100644 --- a/src/Symfony/Component/Notifier/Bridge/ContactEveryone/ContactEveryoneTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/ContactEveryone/ContactEveryoneTransport.php @@ -73,7 +73,9 @@ protected function doSend(MessageInterface $message): SentMessage } $options = $message->getOptions()?->toArray() ?? []; - $options['xcharset'] = 'true'; + $options['category'] ??= $this->category; + $options['diffusionname'] ??= $this->diffusionName; + $options['xcharset'] ??= 'true'; $options['token'] = $this->token; $options['to'] = $message->getPhone(); $options['msg'] = $message->getSubject(); diff --git a/src/Symfony/Component/Notifier/Bridge/ContactEveryone/Tests/ContactEveryoneOptionsTest.php b/src/Symfony/Component/Notifier/Bridge/ContactEveryone/Tests/ContactEveryoneOptionsTest.php index 89b367509bd88..4485d18e5b3b3 100644 --- a/src/Symfony/Component/Notifier/Bridge/ContactEveryone/Tests/ContactEveryoneOptionsTest.php +++ b/src/Symfony/Component/Notifier/Bridge/ContactEveryone/Tests/ContactEveryoneOptionsTest.php @@ -24,7 +24,7 @@ public function testContactEveryoneOptions() self::assertSame([ 'category' => 'test_category', - 'diffusion_name' => 'test_diffusion_name', + 'diffusionname' => 'test_diffusion_name', ], $contactEveryoneOptions->toArray()); } }