-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Notifier] [Mobyt] Change ctor signature and validate message types #39587
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
Conversation
e24af00
to
4c5f459
Compare
Ready to merge from my side 👌🏻 |
4c5f459
to
d797ac8
Compare
Rebased |
e54f539
to
f47c319
Compare
f47c319
to
81358ae
Compare
9aecc44
to
533f7ab
Compare
I think I won't change my mind. Message type is way worse than quality. I don't any good reason to change it. |
Ok, I will rework the PR to validate the allowed types and remove the BC break |
a0218fc
to
cc33680
Compare
@@ -33,11 +33,15 @@ final class MobytTransport extends AbstractTransport | |||
private $from; | |||
private $typeQuality; | |||
|
|||
public function __construct(string $accountSid, string $authToken, string $from, string $typeQuality, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null) | |||
public function __construct(string $accountSid, string $authToken, string $from, string $typeQuality = null, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null) |
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.
Why do we want to make that parameter nullable anyway?
public function __construct(string $accountSid, string $authToken, string $from, string $typeQuality = null, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null) | |
public function __construct(string $accountSid, string $authToken, string $from, string $typeQuality = MobytOptions::MESSAGE_TYPE_QUALITY_LOW, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null) |
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.
I would suggest that staying BC from the ctor signature is easier if the default value can be handled in the ctor itself, isn't it? 🤔
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.
Ah and we need to know the default value in the transport factory too:
symfony/src/Symfony/Component/Notifier/Bridge/Mobyt/MobytTransportFactory.php
Lines 27 to 43 in 73509d9
public function create(Dsn $dsn): TransportInterface | |
{ | |
$scheme = $dsn->getScheme(); | |
if ('mobyt' !== $scheme) { | |
throw new UnsupportedSchemeException($dsn, 'mobyt', $this->getSupportedSchemes()); | |
} | |
$accountSid = $this->getUser($dsn); | |
$authToken = $this->getPassword($dsn); | |
$from = $dsn->getRequiredOption('from'); | |
$typeQuality = $dsn->getOption('type_quality', MobytOptions::MESSAGE_TYPE_QUALITY_LOW); | |
$host = 'default' === $dsn->getHost() ? null : $dsn->getHost(); | |
$port = $dsn->getPort(); | |
return (new MobytTransport($accountSid, $authToken, $from, $typeQuality, $this->client, $this->dispatcher))->setHost($host)->setPort($port); | |
} |
By using null, only the transport sets and knows about the default value
7112892
to
8c6c3c7
Compare
d5b27cc
to
e5e2cd4
Compare
Thank you @OskarStark. |
cc @Deamon as you provided the bridge