diff --git a/extensions/swiftmailer/yii/swiftmailer/Message.php b/extensions/swiftmailer/yii/swiftmailer/Message.php index 7cf3032..8ae3ee4 100644 --- a/extensions/swiftmailer/yii/swiftmailer/Message.php +++ b/extensions/swiftmailer/yii/swiftmailer/Message.php @@ -115,7 +115,7 @@ class Message extends BaseMessage /** * @inheritdoc */ - public function createAttachment($content, $fileName, $contentType = 'application/octet-stream') + public function attachContentAsFile($content, $fileName, $contentType = 'application/octet-stream') { if (empty($contentType)) { $contentType = 'application/octet-stream'; diff --git a/framework/yii/mail/BaseMessage.php b/framework/yii/mail/BaseMessage.php index 17658f4..5593cec 100644 --- a/framework/yii/mail/BaseMessage.php +++ b/framework/yii/mail/BaseMessage.php @@ -75,7 +75,7 @@ abstract class BaseMessage extends Object implements MessageInterface $attachFileName = basename($fileName); } $content = file_get_contents($fileName); - $this->createAttachment($content, $attachFileName, $contentType); + $this->attachContentAsFile($content, $attachFileName, $contentType); } /** diff --git a/framework/yii/mail/MessageInterface.php b/framework/yii/mail/MessageInterface.php index c592edb..28223a4 100644 --- a/framework/yii/mail/MessageInterface.php +++ b/framework/yii/mail/MessageInterface.php @@ -82,12 +82,12 @@ interface MessageInterface public function addHtml($html); /** - * Create file attachment for the email message. + * Attach specified content as file for the email message. * @param string $content attachment file content. * @param string $fileName attachment file name. * @param string $contentType MIME type of the attachment file, by default 'application/octet-stream' will be used. */ - public function createAttachment($content, $fileName, $contentType = 'application/octet-stream'); + public function attachContentAsFile($content, $fileName, $contentType = 'application/octet-stream'); /** * Attaches existing file to the email message. diff --git a/tests/unit/extensions/swiftmailer/MessageTest.php b/tests/unit/extensions/swiftmailer/MessageTest.php index 530d725..dabe831 100644 --- a/tests/unit/extensions/swiftmailer/MessageTest.php +++ b/tests/unit/extensions/swiftmailer/MessageTest.php @@ -82,7 +82,7 @@ class MessageTest extends VendorTestCase $message->setFrom('someuser@somedomain.com'); $message->setSubject('Yii Swift Create Attachment Test'); $message->setText('Yii Swift Create Attachment Test body'); - $message->createAttachment('Test attachment content', 'test.txt'); + $message->attachContentAsFile('Test attachment content', 'test.txt'); $this->assertTrue($message->send()); } diff --git a/tests/unit/framework/mail/BaseMailerTest.php b/tests/unit/framework/mail/BaseMailerTest.php index 88d6a4e..95bd836 100644 --- a/tests/unit/framework/mail/BaseMailerTest.php +++ b/tests/unit/framework/mail/BaseMailerTest.php @@ -187,5 +187,5 @@ class Message extends BaseMessage public function addHtml($html) {} - public function createAttachment($content, $fileName, $contentType = 'application/octet-stream') {} + public function attachContentAsFile($content, $fileName, $contentType = 'application/octet-stream') {} } \ No newline at end of file