Commit 104cfd7c by Paul Klimov

'yii\mail\MessageInterface' methods renamed: 'text' to 'textBody', 'html' to 'htmlBody'

parent 1aafa73e
......@@ -97,7 +97,7 @@ class Message extends BaseMessage
/**
* @inheritdoc
*/
public function text($text)
public function textBody($text)
{
$this->setBody($text, 'text/plain');
return $this;
......@@ -106,7 +106,7 @@ class Message extends BaseMessage
/**
* @inheritdoc
*/
public function html($html)
public function htmlBody($html)
{
$this->setBody($html, 'text/html');
return $this;
......
......@@ -52,8 +52,8 @@ abstract class BaseMailer extends Component implements MailerInterface, ViewCont
* - 'cc' argument for [[MessageInterface::cc()]]
* - 'bcc' argument for [[MessageInterface::bcc()]]
* - 'subject' argument for [[MessageInterface::subject()]]
* - 'text' argument for [[MessageInterface::text()]]
* - 'html' argument for [[MessageInterface::html()]]
* - 'textBody' argument for [[MessageInterface::textBody()]]
* - 'htmlBody' argument for [[MessageInterface::htmlBody()]]
* For example:
* ~~~
* array(
......@@ -115,15 +115,15 @@ abstract class BaseMailer extends Component implements MailerInterface, ViewCont
$params['message'] = $message;
if (is_array($view)) {
if (array_key_exists('html', $view)) {
$message->html($this->render($view['html'], $params, $this->htmlLayout));
$message->htmlBody($this->render($view['html'], $params, $this->htmlLayout));
}
if (array_key_exists('text', $view)) {
$message->text($this->render($view['text'], $params, $this->textLayout));
$message->textBody($this->render($view['text'], $params, $this->textLayout));
}
} else {
$html = $this->render($view, $params, $this->htmlLayout);
$message->html($html);
$message->text(strip_tags($html));
$message->htmlBody($html);
$message->textBody(strip_tags($html));
}
}
return $message;
......@@ -147,8 +147,8 @@ abstract class BaseMailer extends Component implements MailerInterface, ViewCont
'cc',
'bcc',
'subject',
'text',
'html',
'textBody',
'htmlBody',
];
$directSetterConfig = [];
foreach ($config as $name => $value) {
......
......@@ -87,14 +87,14 @@ interface MessageInterface
* @param string $text message plain text content.
* @return static self reference.
*/
public function text($text);
public function textBody($text);
/**
* Sets message HTML content.
* @param string $html message HTML content.
* @return static self reference.
*/
public function html($html);
public function htmlBody($html);
/**
* Attaches existing file to the email message.
......
......@@ -160,7 +160,7 @@ class MessageTest extends VendorTestCase
$message->to($this->testEmailReceiver);
$message->from('someuser@somedomain.com');
$message->subject('Yii Swift Test');
$message->text('Yii Swift Test body');
$message->textBody('Yii Swift Test body');
$this->assertTrue($message->send());
}
......@@ -174,7 +174,7 @@ class MessageTest extends VendorTestCase
$message->to($this->testEmailReceiver);
$message->from('someuser@somedomain.com');
$message->subject('Yii Swift Attach File Test');
$message->text('Yii Swift Attach File Test body');
$message->textBody('Yii Swift Attach File Test body');
$fileName = __FILE__;
$message->attach($fileName);
......@@ -195,7 +195,7 @@ class MessageTest extends VendorTestCase
$message->to($this->testEmailReceiver);
$message->from('someuser@somedomain.com');
$message->subject('Yii Swift Create Attachment Test');
$message->text('Yii Swift Create Attachment Test body');
$message->textBody('Yii Swift Create Attachment Test body');
$fileName = 'test.txt';
$fileContent = 'Test attachment content';
$message->attachContent($fileContent, ['fileName' => $fileName]);
......@@ -221,7 +221,7 @@ class MessageTest extends VendorTestCase
$message->to($this->testEmailReceiver);
$message->from('someuser@somedomain.com');
$message->subject('Yii Swift Embed File Test');
$message->html('Embed image: <img src="' . $cid. '" alt="pic">');
$message->htmlBody('Embed image: <img src="' . $cid. '" alt="pic">');
$this->assertTrue($message->send());
......@@ -247,7 +247,7 @@ class MessageTest extends VendorTestCase
$message->to($this->testEmailReceiver);
$message->from('someuser@somedomain.com');
$message->subject('Yii Swift Embed File Test');
$message->html('Embed image: <img src="' . $cid. '" alt="pic">');
$message->htmlBody('Embed image: <img src="' . $cid. '" alt="pic">');
$this->assertTrue($message->send());
......@@ -267,8 +267,8 @@ class MessageTest extends VendorTestCase
$message->to($this->testEmailReceiver);
$message->from('someuser@somedomain.com');
$message->subject('Yii Swift Alternative Body Test');
$message->html('<b>Yii Swift</b> test HTML body');
$message->text('Yii Swift test plain text body');
$message->htmlBody('<b>Yii Swift</b> test HTML body');
$message->textBody('Yii Swift test plain text body');
$this->assertTrue($message->send());
......@@ -300,7 +300,7 @@ class MessageTest extends VendorTestCase
$message->to($this->testEmailReceiver);
$message->from('someuser@somedomain.com');
$message->subject('Yii Swift Alternative Body Test');
$message->text('Yii Swift test plain text body');
$message->textBody('Yii Swift test plain text body');
$serializedMessage = serialize($message);
$this->assertNotEmpty($serializedMessage, 'Unable to serialize message!');
......
......@@ -115,8 +115,8 @@ class BaseMailerTest extends TestCase
'cc' => 'cc@domain.com',
'bcc' => 'bcc@domain.com',
'subject' => 'Test subject',
'text' => 'Test text body',
'html' => 'Test HTML body',
'textBody' => 'Test text body',
'htmlBody' => 'Test HTML body',
];
$propertyConfig = [
'id' => 'test-id',
......@@ -201,12 +201,12 @@ class BaseMailerTest extends TestCase
'html' => $htmlViewName,
'text' => $textViewName,
]);
$this->assertEquals($htmlViewFileContent, $message->_html, 'Unable to render html!');
$this->assertEquals($textViewFileContent, $message->_text, 'Unable to render text!');
$this->assertEquals($htmlViewFileContent, $message->_htmlBody, 'Unable to render html!');
$this->assertEquals($textViewFileContent, $message->_textBody, 'Unable to render text!');
$message = $mailer->compose($htmlViewName);
$this->assertEquals($htmlViewFileContent, $message->_html, 'Unable to render html by direct view!');
$this->assertEquals(strip_tags($htmlViewFileContent), $message->_text, 'Unable to render text by direct view!');
$this->assertEquals($htmlViewFileContent, $message->_htmlBody, 'Unable to render html by direct view!');
$this->assertEquals(strip_tags($htmlViewFileContent), $message->_textBody, 'Unable to render text by direct view!');
}
}
......@@ -237,8 +237,8 @@ class Message extends BaseMessage
public $_cc;
public $_bcc;
public $_subject;
public $_text;
public $_html;
public $_textBody;
public $_htmlBody;
public function charset($charset)
{
......@@ -276,15 +276,15 @@ class Message extends BaseMessage
return $this;
}
public function text($text)
public function textBody($text)
{
$this->_text = $text;
$this->_textBody = $text;
return $this;
}
public function html($html)
public function htmlBody($html)
{
$this->_html = $html;
$this->_htmlBody = $html;
return $this;
}
......
......@@ -97,11 +97,11 @@ class TestMessage extends BaseMessage
public function subject($subject) {}
public function text($text) {
public function textBody($text) {
$this->text = $text;
}
public function html($html) {
public function htmlBody($html) {
$this->html = $html;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment