Skip to content

Commit bf015b7

Browse files
ENGCOM-7282: Fix hard-code scope store string #26926
- Merge Pull Request #26926 from mrtuvn/magento2:fix/hard-code-scope-store-customer-email-notification - Merged commits: 1. e06f660 2. 889e676 3. b4debc7 4. fe7611f 5. 602100b 6. 1d82536 7. 4d4036d 8. 0989a31
2 parents e344d30 + 0989a31 commit bf015b7

File tree

2 files changed

+259
-174
lines changed

2 files changed

+259
-174
lines changed

app/code/Magento/Customer/Model/EmailNotification.php

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
67

78
namespace Magento\Customer\Model;
89

@@ -15,6 +16,8 @@
1516
use Magento\Customer\Api\Data\CustomerInterface;
1617
use Magento\Framework\Reflection\DataObjectProcessor;
1718
use Magento\Framework\Exception\LocalizedException;
19+
use Magento\Store\Model\ScopeInterface;
20+
use Magento\Customer\Model\Data\CustomerSecure;
1821

1922
/**
2023
* Customer email notification
@@ -124,7 +127,7 @@ public function __construct(
124127
$this->customerViewHelper = $customerViewHelper;
125128
$this->dataProcessor = $dataProcessor;
126129
$this->scopeConfig = $scopeConfig;
127-
$this->senderResolver = $senderResolver ?: ObjectManager::getInstance()->get(SenderResolverInterface::class);
130+
$this->senderResolver = $senderResolver ?? ObjectManager::getInstance()->get(SenderResolverInterface::class);
128131
}
129132

130133
/**
@@ -139,7 +142,7 @@ public function credentialsChanged(
139142
CustomerInterface $savedCustomer,
140143
$origCustomerEmail,
141144
$isPasswordChanged = false
142-
) {
145+
): void {
143146
if ($origCustomerEmail != $savedCustomer->getEmail()) {
144147
if ($isPasswordChanged) {
145148
$this->emailAndPasswordChanged($savedCustomer, $origCustomerEmail);
@@ -164,7 +167,7 @@ public function credentialsChanged(
164167
* @param string $email
165168
* @return void
166169
*/
167-
private function emailAndPasswordChanged(CustomerInterface $customer, $email)
170+
private function emailAndPasswordChanged(CustomerInterface $customer, $email): void
168171
{
169172
$storeId = $customer->getStoreId();
170173
if (!$storeId) {
@@ -190,7 +193,7 @@ private function emailAndPasswordChanged(CustomerInterface $customer, $email)
190193
* @param string $email
191194
* @return void
192195
*/
193-
private function emailChanged(CustomerInterface $customer, $email)
196+
private function emailChanged(CustomerInterface $customer, $email): void
194197
{
195198
$storeId = $customer->getStoreId();
196199
if (!$storeId) {
@@ -215,7 +218,7 @@ private function emailChanged(CustomerInterface $customer, $email)
215218
* @param CustomerInterface $customer
216219
* @return void
217220
*/
218-
private function passwordReset(CustomerInterface $customer)
221+
private function passwordReset(CustomerInterface $customer): void
219222
{
220223
$storeId = $customer->getStoreId();
221224
if (!$storeId) {
@@ -252,15 +255,15 @@ private function sendEmailTemplate(
252255
$templateParams = [],
253256
$storeId = null,
254257
$email = null
255-
) {
256-
$templateId = $this->scopeConfig->getValue($template, 'store', $storeId);
258+
): void {
259+
$templateId = $this->scopeConfig->getValue($template, ScopeInterface::SCOPE_STORE, $storeId);
257260
if ($email === null) {
258261
$email = $customer->getEmail();
259262
}
260263

261264
/** @var array $from */
262265
$from = $this->senderResolver->resolve(
263-
$this->scopeConfig->getValue($sender, 'store', $storeId),
266+
$this->scopeConfig->getValue($sender, ScopeInterface::SCOPE_STORE, $storeId),
264267
$storeId
265268
);
266269

@@ -278,15 +281,15 @@ private function sendEmailTemplate(
278281
* Create an object with data merged from Customer and CustomerSecure
279282
*
280283
* @param CustomerInterface $customer
281-
* @return \Magento\Customer\Model\Data\CustomerSecure
284+
* @return CustomerSecure
282285
*/
283-
private function getFullCustomerObject($customer)
286+
private function getFullCustomerObject($customer): CustomerSecure
284287
{
285288
// No need to flatten the custom attributes or nested objects since the only usage is for email templates and
286289
// object passed for events
287290
$mergedCustomerData = $this->customerRegistry->retrieveSecureData($customer->getId());
288291
$customerData = $this->dataProcessor
289-
->buildOutputDataArray($customer, \Magento\Customer\Api\Data\CustomerInterface::class);
292+
->buildOutputDataArray($customer, CustomerInterface::class);
290293
$mergedCustomerData->addData($customerData);
291294
$mergedCustomerData->setData('name', $this->customerViewHelper->getCustomerName($customer));
292295
return $mergedCustomerData;
@@ -299,7 +302,7 @@ private function getFullCustomerObject($customer)
299302
* @param int|string|null $defaultStoreId
300303
* @return int
301304
*/
302-
private function getWebsiteStoreId($customer, $defaultStoreId = null)
305+
private function getWebsiteStoreId($customer, $defaultStoreId = null): int
303306
{
304307
if ($customer->getWebsiteId() != 0 && empty($defaultStoreId)) {
305308
$storeIds = $this->storeManager->getWebsite($customer->getWebsiteId())->getStoreIds();
@@ -314,7 +317,7 @@ private function getWebsiteStoreId($customer, $defaultStoreId = null)
314317
* @param CustomerInterface $customer
315318
* @return void
316319
*/
317-
public function passwordReminder(CustomerInterface $customer)
320+
public function passwordReminder(CustomerInterface $customer): void
318321
{
319322
$storeId = $customer->getStoreId();
320323
if (!$storeId) {
@@ -338,7 +341,7 @@ public function passwordReminder(CustomerInterface $customer)
338341
* @param CustomerInterface $customer
339342
* @return void
340343
*/
341-
public function passwordResetConfirmation(CustomerInterface $customer)
344+
public function passwordResetConfirmation(CustomerInterface $customer): void
342345
{
343346
$storeId = $customer->getStoreId();
344347
if (!$storeId) {
@@ -373,7 +376,7 @@ public function newAccount(
373376
$backUrl = '',
374377
$storeId = 0,
375378
$sendemailStoreId = null
376-
) {
379+
): void {
377380
$types = self::TEMPLATE_TYPES;
378381

379382
if (!isset($types[$type])) {

0 commit comments

Comments
 (0)