Skip to content

[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

Merged
merged 1 commit into from
Jul 17, 2019

Conversation

Koc
Copy link
Contributor

@Koc Koc commented Jun 7, 2019

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:

  • Update changelog
  • Add more tests for factories
  • Add test for configuration + DI extension

fabpot added a commit that referenced this pull request Jun 11, 2019
…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
@Koc Koc force-pushed the mailer-transport-factory branch 3 times, most recently from 816f403 to 9af7d94 Compare June 11, 2019 20:23
Copy link
Member

@fabpot fabpot left a 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.

@Koc
Copy link
Contributor Author

Koc commented Jun 30, 2019

@fabpot I've fixed comments from code review. Now working on adding tests (I've updated TODO list in PR header)

@Koc Koc marked this pull request as ready for review June 30, 2019 19:04
@Koc Koc force-pushed the mailer-transport-factory branch from 593acbc to 02aa069 Compare June 30, 2019 19:06
Copy link
Contributor

@Taluu Taluu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome. 👍

@Koc
Copy link
Contributor Author

Koc commented Jul 7, 2019

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.

Copy link
Member

@fabpot fabpot left a 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!

@Koc Koc force-pushed the mailer-transport-factory branch from aea9b37 to a016fc2 Compare July 14, 2019 08:00
@Koc Koc force-pushed the mailer-transport-factory branch 2 times, most recently from 29d9a30 to 5029ed6 Compare July 14, 2019 15:01
@fabpot
Copy link
Member

fabpot commented Jul 15, 2019

Not sure if this PR is ready now but fabbot has an interesting patch to apply.

@Koc
Copy link
Contributor Author

Koc commented Jul 15, 2019

Almost ready. Failure caused because #32553 not merged yet.

@fabpot
Copy link
Member

fabpot commented Jul 16, 2019

@Koc #32553 has been merged now

@Koc Koc force-pushed the mailer-transport-factory branch from 1d701e1 to 5b9cded Compare July 16, 2019 19:16
@Koc
Copy link
Contributor Author

Koc commented Jul 16, 2019

Finally PR is ready 🎉

Travis is green except deps=high (because master hasn't this PR yet). To be honest I still haven't performed manual testing of the branch, but we already have test for DI extension and each factory properly tested.

@fabpot
Copy link
Member

fabpot commented Jul 17, 2019

Thank you @Koc.

@fabpot fabpot merged commit 5b9cded into symfony:4.4 Jul 17, 2019
fabpot added a commit that referenced this pull request Jul 17, 2019
…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);
Copy link
Member

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see 2887724

Copy link
Contributor Author

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

Copy link
Contributor

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).

@Koc Koc deleted the mailer-transport-factory branch July 22, 2019 12:10
fabpot added a commit that referenced this pull request Jul 25, 2019
…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
@nicolas-grekas nicolas-grekas modified the milestones: next, 4.4 Oct 27, 2019
This was referenced Nov 12, 2019
javiereguiluz added a commit to symfony/symfony-docs that referenced this pull request Jan 18, 2024
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants