Skip to content

Commit b6f9e48

Browse files
author
Graham Wharton
committed
Added new setFromByStore function and deprecated old function.
TODO : Rest of Magento codebase still uses deprecated setFrom
1 parent 621d2cf commit b6f9e48

File tree

4 files changed

+24
-9
lines changed

4 files changed

+24
-9
lines changed

app/code/Magento/Sales/Model/Order/Email/SenderBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ protected function configureEmailTemplate()
101101
$this->transportBuilder->setTemplateIdentifier($this->templateContainer->getTemplateId());
102102
$this->transportBuilder->setTemplateOptions($this->templateContainer->getTemplateOptions());
103103
$this->transportBuilder->setTemplateVars($this->templateContainer->getTemplateVars());
104-
$this->transportBuilder->setFrom(
104+
$this->transportBuilder->setFromByStore(
105105
$this->identityContainer->getEmailIdentity(),
106106
$this->identityContainer->getStore()->getId()
107107
);

app/code/Magento/Sales/Test/Unit/Model/Order/Email/SenderBuilderTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ protected function setUp()
7676
'setTemplateIdentifier',
7777
'setTemplateOptions',
7878
'setTemplateVars',
79-
'setFrom',
79+
'setFromByStore',
8080
]
8181
);
8282

@@ -103,8 +103,8 @@ protected function setUp()
103103
->method('getEmailIdentity')
104104
->will($this->returnValue($emailIdentity));
105105
$this->transportBuilder->expects($this->once())
106-
->method('setFrom')
107-
->with($this->equalTo($emailIdentity));
106+
->method('setFromByStore')
107+
->with($this->equalTo($emailIdentity), 1);
108108

109109
$this->identityContainerMock->expects($this->once())
110110
->method('getEmailCopyTo')
@@ -146,7 +146,7 @@ public function testSend()
146146
->method('getId')
147147
->willReturn(1);
148148
$this->transportBuilder->expects($this->once())
149-
->method('setFrom')
149+
->method('setFromByStore')
150150
->with($identity, 1);
151151
$this->transportBuilder->expects($this->once())
152152
->method('addTo')
@@ -176,7 +176,7 @@ public function testSendCopyTo()
176176
->method('addTo')
177177
->with($this->equalTo('[email protected]'));
178178
$this->transportBuilder->expects($this->once())
179-
->method('setFrom')
179+
->method('setFromByStore')
180180
->with($identity, 1);
181181
$this->identityContainerMock->expects($this->once())
182182
->method('getStore')

lib/internal/Magento/Framework/Mail/Template/TransportBuilder.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,9 @@ public function setReplyTo($email, $name = null)
177177
/**
178178
* Set mail from address
179179
*
180+
* @deprecated Use setFromByStore
181+
*
180182
* @param string|array $from
181-
* @param string|int $store
182183
* @return $this
183184
*/
184185
public function setFrom($from, $store = null)
@@ -188,6 +189,20 @@ public function setFrom($from, $store = null)
188189
return $this;
189190
}
190191

192+
/**
193+
* Set mail from address by store
194+
*
195+
* @param string|array $from
196+
* @param string|int $store
197+
* @return $this
198+
*/
199+
public function setFromByStore($from, $store = null)
200+
{
201+
$result = $this->_senderResolver->resolve($from, $store);
202+
$this->message->setFrom($result['email'], $result['name']);
203+
return $this;
204+
}
205+
191206
/**
192207
* Set template identifier
193208
*

lib/internal/Magento/Framework/Mail/Test/Unit/Template/TransportBuilderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,11 @@ public function testSetFrom()
176176
->with($sender, $store)
177177
->willReturn($sender);
178178
$this->messageMock->expects($this->once())
179-
->method('setFrom')
179+
->method('setFromByStore')
180180
->with('[email protected]', 'name')
181181
->willReturnSelf();
182182

183-
$this->builder->setFrom($sender, $store);
183+
$this->builder->setFromByStore($sender, $store);
184184
}
185185

186186
/**

0 commit comments

Comments
 (0)