Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
3d1a625c
Commit
3d1a625c
authored
Nov 06, 2013
by
Paul Klimov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
'yii\mail\MessageInterface' updated:
- 'body()' renamed to 'renderBody()' - new 'body()' method introduced
parent
b0c5981d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
8 deletions
+34
-8
BaseMailer.php
framework/yii/mail/BaseMailer.php
+4
-2
BaseMessage.php
framework/yii/mail/BaseMessage.php
+17
-3
MessageInterface.php
framework/yii/mail/MessageInterface.php
+11
-1
BaseMessageTest.php
tests/unit/framework/mail/BaseMessageTest.php
+2
-2
No files found.
framework/yii/mail/BaseMailer.php
View file @
3d1a625c
...
...
@@ -54,9 +54,10 @@ abstract class BaseMailer extends Component implements MailerInterface, ViewCont
* - 'subject' argument for [[MessageInterface::subject()]]
* - 'text' argument for [[MessageInterface::text()]]
* - 'html' argument for [[MessageInterface::html()]]
* - 'body' argument for [[MessageInterface::body()]]
* - 'renderText' list of arguments for [[MessageInterface::renderText()]]
* - 'renderHtml' list of arguments for [[MessageInterface::renderHtml()]]
* - '
body' list of arguments for [[MessageInterface::b
ody()]]
* - '
renderBody' list of arguments for [[MessageInterface::renderB
ody()]]
* For example:
* ~~~
* array(
...
...
@@ -132,11 +133,12 @@ abstract class BaseMailer extends Component implements MailerInterface, ViewCont
'subject'
,
'text'
,
'html'
,
'body'
,
];
$setupMethodNames
=
[
'renderText'
,
'renderHtml'
,
'
b
ody'
,
'
renderB
ody'
,
];
$directSetterConfig
=
[];
$setupMethodConfig
=
[];
...
...
framework/yii/mail/BaseMessage.php
View file @
3d1a625c
...
...
@@ -46,6 +46,21 @@ abstract class BaseMessage extends Object implements MessageInterface
/**
* @inheritdoc
*/
public
function
body
(
$body
)
{
if
(
is_array
(
$body
))
{
$this
->
html
(
$body
[
'html'
]);
$this
->
text
(
$body
[
'text'
]);
}
else
{
$this
->
html
(
$body
);
$this
->
text
(
strip_tags
(
$body
));
}
return
$this
;
}
/**
* @inheritdoc
*/
public
function
renderHtml
(
$view
,
$params
=
[])
{
$this
->
html
(
$this
->
getMailer
()
->
render
(
$view
,
$params
,
$this
->
getMailer
()
->
htmlLayout
));
...
...
@@ -64,15 +79,14 @@ abstract class BaseMessage extends Object implements MessageInterface
/**
* @inheritdoc
*/
public
function
b
ody
(
$view
,
$params
=
[])
public
function
renderB
ody
(
$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
));
$this
->
body
(
$html
);
}
return
$this
;
}
...
...
framework/yii/mail/MessageInterface.php
View file @
3d1a625c
...
...
@@ -97,6 +97,16 @@ interface MessageInterface
public
function
html
(
$html
);
/**
* Sets message HTML and plain text content.
* @param string|array $body varies method behavior depending on type:
* - string - the HTML body content, in this case text body will be composed from
* html one using [[strip_tags()]] function.
* - array - list of body contents for each body type in format: ['html' => 'htmlContent', 'text' => 'textContent']
* @return static self reference.
*/
public
function
body
(
$body
);
/**
* Attaches existing file to the email message.
* @param string $fileName full file name
* @param array $options options for embed file. Valid options are:
...
...
@@ -175,7 +185,7 @@ interface MessageInterface
* @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
b
ody
(
$view
,
$params
=
[]);
public
function
renderB
ody
(
$view
,
$params
=
[]);
/**
* Returns string representation of this message.
...
...
tests/unit/framework/mail/BaseMessageTest.php
View file @
3d1a625c
...
...
@@ -65,7 +65,7 @@ class BaseMessageTest extends TestCase
$message
=
$mailer
->
compose
();
$viewName
=
'test/html/view'
;
$message
->
b
ody
(
$viewName
);
$message
->
renderB
ody
(
$viewName
);
$expectedHtml
=
'view='
.
$viewName
.
' layout='
.
$mailer
->
htmlLayout
;
$this
->
assertEquals
(
$expectedHtml
,
$message
->
html
,
'Unable to compose html!'
);
$expectedText
=
strip_tags
(
$expectedHtml
);
...
...
@@ -73,7 +73,7 @@ class BaseMessageTest extends TestCase
$textViewName
=
'test/text/view'
;
$htmlViewName
=
'test/html/view'
;
$message
->
b
ody
([
'text'
=>
$textViewName
,
'html'
=>
$htmlViewName
]);
$message
->
renderB
ody
([
'text'
=>
$textViewName
,
'html'
=>
$htmlViewName
]);
$expectedHtml
=
'view='
.
$htmlViewName
.
' layout='
.
$mailer
->
htmlLayout
;
$this
->
assertEquals
(
$expectedHtml
,
$message
->
html
,
'Unable to compose html from separated view!'
);
$expectedText
=
'view='
.
$textViewName
.
' layout='
.
$mailer
->
textLayout
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment