Refactor Email system to builder pattern #436
Draft
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.
@effgarces Please note that the original PR #426 as well as this was just an incomplete draft. Also #425 in not yet finished in this PR. I just spent a lot of work for this refactoring, so I wanted to share it. But currently I have not time to complete the work.
So here is the rest of the description of the original PR #426:
When I was working on a feature it was quite difficult to implement it because of the current architecture of the email system. This PR holds the current state of my approach, but as it was too risky to break something else I stopped working on it. Maybe it's something for Version 3.0?
The
EmailMessage
is the base class for all message types and implements an interface. Some of the derived classes have aGetTemplateName
method, some don't.I thought the reason for the architecture is because of a manipulation of the
EmailMessage
object after it's creation. But it seems that is not the case. All code paths I found create the message and send it to phpmailer without additional modification.I tried to replace it with a more straighforward builder pattern.
So far I replaced the first view classes with the builder pattern approach. When I came accross
GuestAddedEmail
wich derives fromReservationEmailMessage
things got more complicated. I think this could still be resolved when using a mixture of the builder pattern and the derived class pattern here.Todos:
EmailMessage