3
3
* Copyright © Magento, Inc. All rights reserved.
4
4
* See COPYING.txt for license details.
5
5
*/
6
+ declare (strict_types=1 );
6
7
7
8
namespace Magento \Customer \Model ;
8
9
15
16
use Magento \Customer \Api \Data \CustomerInterface ;
16
17
use Magento \Framework \Reflection \DataObjectProcessor ;
17
18
use Magento \Framework \Exception \LocalizedException ;
19
+ use Magento \Store \Model \ScopeInterface ;
20
+ use Magento \Customer \Model \Data \CustomerSecure ;
18
21
19
22
/**
20
23
* Customer email notification
@@ -124,7 +127,7 @@ public function __construct(
124
127
$ this ->customerViewHelper = $ customerViewHelper ;
125
128
$ this ->dataProcessor = $ dataProcessor ;
126
129
$ this ->scopeConfig = $ scopeConfig ;
127
- $ this ->senderResolver = $ senderResolver ?: ObjectManager::getInstance ()->get (SenderResolverInterface::class);
130
+ $ this ->senderResolver = $ senderResolver ?? ObjectManager::getInstance ()->get (SenderResolverInterface::class);
128
131
}
129
132
130
133
/**
@@ -139,7 +142,7 @@ public function credentialsChanged(
139
142
CustomerInterface $ savedCustomer ,
140
143
$ origCustomerEmail ,
141
144
$ isPasswordChanged = false
142
- ) {
145
+ ): void {
143
146
if ($ origCustomerEmail != $ savedCustomer ->getEmail ()) {
144
147
if ($ isPasswordChanged ) {
145
148
$ this ->emailAndPasswordChanged ($ savedCustomer , $ origCustomerEmail );
@@ -164,7 +167,7 @@ public function credentialsChanged(
164
167
* @param string $email
165
168
* @return void
166
169
*/
167
- private function emailAndPasswordChanged (CustomerInterface $ customer , $ email )
170
+ private function emailAndPasswordChanged (CustomerInterface $ customer , $ email ): void
168
171
{
169
172
$ storeId = $ customer ->getStoreId ();
170
173
if (!$ storeId ) {
@@ -190,7 +193,7 @@ private function emailAndPasswordChanged(CustomerInterface $customer, $email)
190
193
* @param string $email
191
194
* @return void
192
195
*/
193
- private function emailChanged (CustomerInterface $ customer , $ email )
196
+ private function emailChanged (CustomerInterface $ customer , $ email ): void
194
197
{
195
198
$ storeId = $ customer ->getStoreId ();
196
199
if (!$ storeId ) {
@@ -215,7 +218,7 @@ private function emailChanged(CustomerInterface $customer, $email)
215
218
* @param CustomerInterface $customer
216
219
* @return void
217
220
*/
218
- private function passwordReset (CustomerInterface $ customer )
221
+ private function passwordReset (CustomerInterface $ customer ): void
219
222
{
220
223
$ storeId = $ customer ->getStoreId ();
221
224
if (!$ storeId ) {
@@ -252,15 +255,15 @@ private function sendEmailTemplate(
252
255
$ templateParams = [],
253
256
$ storeId = null ,
254
257
$ email = null
255
- ) {
256
- $ templateId = $ this ->scopeConfig ->getValue ($ template , ' store ' , $ storeId );
258
+ ): void {
259
+ $ templateId = $ this ->scopeConfig ->getValue ($ template , ScopeInterface:: SCOPE_STORE , $ storeId );
257
260
if ($ email === null ) {
258
261
$ email = $ customer ->getEmail ();
259
262
}
260
263
261
264
/** @var array $from */
262
265
$ from = $ this ->senderResolver ->resolve (
263
- $ this ->scopeConfig ->getValue ($ sender , ' store ' , $ storeId ),
266
+ $ this ->scopeConfig ->getValue ($ sender , ScopeInterface:: SCOPE_STORE , $ storeId ),
264
267
$ storeId
265
268
);
266
269
@@ -278,15 +281,15 @@ private function sendEmailTemplate(
278
281
* Create an object with data merged from Customer and CustomerSecure
279
282
*
280
283
* @param CustomerInterface $customer
281
- * @return \Magento\Customer\Model\Data\ CustomerSecure
284
+ * @return CustomerSecure
282
285
*/
283
- private function getFullCustomerObject ($ customer )
286
+ private function getFullCustomerObject ($ customer ): CustomerSecure
284
287
{
285
288
// No need to flatten the custom attributes or nested objects since the only usage is for email templates and
286
289
// object passed for events
287
290
$ mergedCustomerData = $ this ->customerRegistry ->retrieveSecureData ($ customer ->getId ());
288
291
$ customerData = $ this ->dataProcessor
289
- ->buildOutputDataArray ($ customer , \ Magento \ Customer \ Api \ Data \ CustomerInterface::class);
292
+ ->buildOutputDataArray ($ customer , CustomerInterface::class);
290
293
$ mergedCustomerData ->addData ($ customerData );
291
294
$ mergedCustomerData ->setData ('name ' , $ this ->customerViewHelper ->getCustomerName ($ customer ));
292
295
return $ mergedCustomerData ;
@@ -299,7 +302,7 @@ private function getFullCustomerObject($customer)
299
302
* @param int|string|null $defaultStoreId
300
303
* @return int
301
304
*/
302
- private function getWebsiteStoreId ($ customer , $ defaultStoreId = null )
305
+ private function getWebsiteStoreId ($ customer , $ defaultStoreId = null ): int
303
306
{
304
307
if ($ customer ->getWebsiteId () != 0 && empty ($ defaultStoreId )) {
305
308
$ storeIds = $ this ->storeManager ->getWebsite ($ customer ->getWebsiteId ())->getStoreIds ();
@@ -314,7 +317,7 @@ private function getWebsiteStoreId($customer, $defaultStoreId = null)
314
317
* @param CustomerInterface $customer
315
318
* @return void
316
319
*/
317
- public function passwordReminder (CustomerInterface $ customer )
320
+ public function passwordReminder (CustomerInterface $ customer ): void
318
321
{
319
322
$ storeId = $ customer ->getStoreId ();
320
323
if (!$ storeId ) {
@@ -338,7 +341,7 @@ public function passwordReminder(CustomerInterface $customer)
338
341
* @param CustomerInterface $customer
339
342
* @return void
340
343
*/
341
- public function passwordResetConfirmation (CustomerInterface $ customer )
344
+ public function passwordResetConfirmation (CustomerInterface $ customer ): void
342
345
{
343
346
$ storeId = $ customer ->getStoreId ();
344
347
if (!$ storeId ) {
@@ -373,7 +376,7 @@ public function newAccount(
373
376
$ backUrl = '' ,
374
377
$ storeId = 0 ,
375
378
$ sendemailStoreId = null
376
- ) {
379
+ ): void {
377
380
$ types = self ::TEMPLATE_TYPES ;
378
381
379
382
if (!isset ($ types [$ type ])) {
0 commit comments