-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Mailer] Extract transport factory and allow create custom transports #31946
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
src/Symfony/Component/Mailer/Transport/AbstractTransportFactory.php
Outdated
Show resolved
Hide resolved
…rom Component to Contracts (Koc) This PR was merged into the 4.4 branch. Discussion ---------- [Mailer] Changed EventDispatcherInterface dependency from Component to Contracts | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no | BC breaks? | yes | Deprecations? | no | Tests pass? | almost yes, see #31956 (comment) | Fixed tickets | - | License | MIT | Doc PR | - Follow up of #31946 (comment) . I hope this kind of changes are allowed for experimental components. BTW, @nicolas-grekas , why Psr14 interface is optional for Contract's `EventDispatcherInterface https://github.com/symfony/symfony/blob/4.4/src/Symfony/Contracts/EventDispatcher/EventDispatcherInterface.php#L16 ? Commits ------- bdb6217 Changed EventDispatcherInterface dependency from Component to Contracts
816f403
to
9af7d94
Compare
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.
Looks promising. Can you finish the PR? We should probably remove the current way or at least deprecate it.
c03a91a
to
510bd0b
Compare
@fabpot I've fixed comments from code review. Now working on adding tests (I've updated TODO list in PR header) |
593acbc
to
02aa069
Compare
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.
Awesome. 👍
2b8200a
to
f542f6f
Compare
I've fixed tests and removed BC-breaks, so bc-break label non-actual anymore. More tests for all factories should be added, but I need 1 week more due to vacation. BTW PR is ready for another round of review. |
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.
Looks good to me. Thanks for the hard work so far!
src/Symfony/Component/Mailer/Transport/Smtp/EsmtpTransportFactory.php
Outdated
Show resolved
Hide resolved
aea9b37
to
a016fc2
Compare
29d9a30
to
5029ed6
Compare
Not sure if this PR is ready now but fabbot has an interesting patch to apply. |
Almost ready. Failure caused because #32553 not merged yet. |
1d701e1
to
5b9cded
Compare
Finally PR is ready 🎉 Travis is green except |
Thank you @Koc. |
…stom transports (Koc) This PR was merged into the 4.4 branch. Discussion ---------- [Mailer] Extract transport factory and allow create custom transports | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes, failure unrelated (master hasn't this PR) | Fixed tickets | #31385, #32523 | License | MIT | Doc PR | TBD Alternative approach to allow create custom transports and register DSN for it. Replaces #31931, #31935 . Similar to already existent TansportFactory from Messenger. TODO: - [x] Update changelog - [x] Add more tests for factories - [x] Add test for configuration + DI extension Commits ------- 5b9cded Add transport factories (closes #31385, closes #32523)
} | ||
|
||
$user = urldecode($parsedDsn['user'] ?? null); | ||
$password = urldecode($parsedDsn['pass'] ?? 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.
this is broken. It is passing null
to urldecode
, and it won't get null
as $user
then.
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.
see 2887724
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.
But it already covered with test https://github.com/symfony/symfony/pull/31946/files#diff-e3a1e78245b60fed36ed6ab4e56023ceR48 . Strange. Maybe because assertEquals
compares ''
equal to 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.
@Koc assertEquals()
does not make a strict comparison unlike assertSame()
. It is therefore recommended to use assertSame()
(or assertNull()
to check the null value).
…es (Koc) This PR was squashed before being merged into the 4.4 branch (closes #32609). Discussion ---------- [Mailer][DX][RFC] Rename mailer bridge transport classes | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yno | New feature? | no | BC breaks? | yes | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - During working on #31946 I realized how painful to work with multiple classes which has same name. [Nice article](https://www.tomasvotruba.cz/blog/2019/05/02/alias-as-a-code-smell/) by @TomasVotruba with explanation of problems with such approach. ~Built on top of #32608 , so only [2nd commit](bbf7e99) is actual.~ Also I've changed namespaces to make bridge structure much simpler and be linear. All classes located on same level now. See how [bridge](https://github.com/symfony/symfony/tree/bbf7e99e89c70fab372929827ae509b41280ce40/src/Symfony/Component/Mailer/Bridge/Amazon) looks like now. Now in RFC state to get approve for such king of changes and update all other bridges. Commits ------- eda4f01 [Mailer][DX][RFC] Rename mailer bridge transport classes
This PR was submitted for the 4.4 branch but it was squashed and merged into the 5.4 branch instead. Discussion ---------- [Mailer] Add custom transport factories This might be useful for very custom use cases where we need to extract some data or do something before being able to create the actual transport. The feature apparently was added here: symfony/symfony#31946 Commits ------- 72b69c1 [Mailer] Add custom transport factories
Alternative approach to allow create custom transports and register DSN for it. Replaces #31931, #31935 . Similar to already existent TansportFactory from Messenger.
TODO: