-
Notifications
You must be signed in to change notification settings - Fork 9.4k
* Added decorator method addAttachment() to allow access to createA… #3803
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -217,6 +217,28 @@ public function setTemplateOptions($templateOptions) | |
return $this; | ||
} | ||
|
||
/** | ||
* Creates a Zend_Mime_Part attachment and attaches it to the current message scope. | ||
* Attachment is automatically added to the mail object after creation. | ||
* | ||
* @param string $body | ||
* @param string $mimeType | ||
* @param string $disposition | ||
* @param string $encoding | ||
* @param string $filename A filename for the attachment | ||
* @return $this | ||
*/ | ||
public function addAttachment( | ||
$body, | ||
$mimeType = \Zend_Mime::TYPE_OCTETSTREAM, | ||
$disposition = \Zend_Mime::DISPOSITION_ATTACHMENT, | ||
$encoding = \Zend_Mime::ENCODING_BASE64, | ||
$filename = null | ||
) { | ||
$this->message->createAttachment($body, $mimeType, $disposition, $encoding, $filename); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As declared in constructor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
First, I do not understand why this should be a backward incompatible change due to the only extensible kind of change and no change on the existing code (new method, no override). Second, the internal message entity attribute is refering to the Magento2 Message entity and not to the Message interface, which is for me a bug itself (see line 71 of Magento2 TransportBuilder). I do not see any more conflict with Magento2 architecture concept or backward compatibilities. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When you add or remove a new method on an interface, you're breaking every other 3rd party implementation of that interface. The high level API is a hard thing to change without pissing people off. @vkublytskyi is not refering to internal classes, but other people's implementation of that interface. And I agree with him that you're leaking implementation details ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @adragus-inviqa thank you for the explanation, the problem is more clear to me now. May the problem be resolved by adding a new message interface (extending the current one) especially for the injection to the transport builder constructor providing the new method? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indeed, there are a couple of ways to tackle this. One Java-ish method would be to create a new Another way would be the Decorator pattern ( Either way, you would still have the problem of leaking implementation details. |
||
return $this; | ||
} | ||
|
||
/** | ||
* Get mail transport | ||
* | ||
|
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.
We should not expose that Zend Framework is used in implementation