mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-17 06:48:59 +08:00
Method 'yii\mail\MessageInterface::body()' added.
This commit is contained in:
@@ -61,4 +61,20 @@ abstract class BaseMessage extends Object implements MessageInterface
|
||||
$this->text($this->getMailer()->render($view, $params, $this->getMailer()->textLayout));
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function body($view, $params = [])
|
||||
{
|
||||
if (is_array($view)) {
|
||||
$this->renderHtml($view['html'], $params);
|
||||
$this->renderText($view['text'], $params);
|
||||
} else {
|
||||
$html = $this->getMailer()->render($view, $params, $this->getMailer()->htmlLayout);
|
||||
$this->html($html);
|
||||
$this->text(strip_tags($html));
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -166,6 +166,17 @@ interface MessageInterface
|
||||
*/
|
||||
public function renderText($view, $params = []);
|
||||
|
||||
/**
|
||||
* Composes the message HTML and plain text body.
|
||||
* @param string|array $view varies method behavior depending on type:
|
||||
* - string - the view name or the path alias of the HTML body view file, in this case
|
||||
* text body will be composed from html one using [[strip_tags()]] function.
|
||||
* - array - list of views for each body type in format: ['html' => 'htmlView', 'text' => 'textView']
|
||||
* @param array $params the parameters (name-value pairs) that will be extracted and made available in the view file.
|
||||
* @return static self reference.
|
||||
*/
|
||||
public function body($view, $params = []);
|
||||
|
||||
/**
|
||||
* String output.
|
||||
* This is PHP magic method that returns string representation of an object.
|
||||
|
||||
Reference in New Issue
Block a user