Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix hard-code scope store string #26926

Merged
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 18 additions & 15 deletions app/code/Magento/Customer/Model/EmailNotification.php
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Customer\Model;

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

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

/**
@@ -139,7 +142,7 @@ public function credentialsChanged(
CustomerInterface $savedCustomer,
$origCustomerEmail,
$isPasswordChanged = false
) {
): void {
if ($origCustomerEmail != $savedCustomer->getEmail()) {
if ($isPasswordChanged) {
$this->emailAndPasswordChanged($savedCustomer, $origCustomerEmail);
@@ -164,7 +167,7 @@ public function credentialsChanged(
* @param string $email
* @return void
*/
private function emailAndPasswordChanged(CustomerInterface $customer, $email)
private function emailAndPasswordChanged(CustomerInterface $customer, $email): void
{
$storeId = $customer->getStoreId();
if (!$storeId) {
@@ -190,7 +193,7 @@ private function emailAndPasswordChanged(CustomerInterface $customer, $email)
* @param string $email
* @return void
*/
private function emailChanged(CustomerInterface $customer, $email)
private function emailChanged(CustomerInterface $customer, $email): void
{
$storeId = $customer->getStoreId();
if (!$storeId) {
@@ -215,7 +218,7 @@ private function emailChanged(CustomerInterface $customer, $email)
* @param CustomerInterface $customer
* @return void
*/
private function passwordReset(CustomerInterface $customer)
private function passwordReset(CustomerInterface $customer): void
{
$storeId = $customer->getStoreId();
if (!$storeId) {
@@ -252,15 +255,15 @@ private function sendEmailTemplate(
$templateParams = [],
$storeId = null,
$email = null
) {
$templateId = $this->scopeConfig->getValue($template, 'store', $storeId);
): void {
$templateId = $this->scopeConfig->getValue($template, ScopeInterface::SCOPE_STORE, $storeId);
if ($email === null) {
$email = $customer->getEmail();
}

/** @var array $from */
$from = $this->senderResolver->resolve(
$this->scopeConfig->getValue($sender, 'store', $storeId),
$this->scopeConfig->getValue($sender, ScopeInterface::SCOPE_STORE, $storeId),
$storeId
);

@@ -278,15 +281,15 @@ private function sendEmailTemplate(
* Create an object with data merged from Customer and CustomerSecure
*
* @param CustomerInterface $customer
* @return \Magento\Customer\Model\Data\CustomerSecure
* @return CustomerSecure
*/
private function getFullCustomerObject($customer)
private function getFullCustomerObject($customer): CustomerSecure
{
// No need to flatten the custom attributes or nested objects since the only usage is for email templates and
// object passed for events
$mergedCustomerData = $this->customerRegistry->retrieveSecureData($customer->getId());
$customerData = $this->dataProcessor
->buildOutputDataArray($customer, \Magento\Customer\Api\Data\CustomerInterface::class);
->buildOutputDataArray($customer, CustomerInterface::class);
$mergedCustomerData->addData($customerData);
$mergedCustomerData->setData('name', $this->customerViewHelper->getCustomerName($customer));
return $mergedCustomerData;
@@ -299,7 +302,7 @@ private function getFullCustomerObject($customer)
* @param int|string|null $defaultStoreId
* @return int
*/
private function getWebsiteStoreId($customer, $defaultStoreId = null)
private function getWebsiteStoreId($customer, $defaultStoreId = null): int
{
if ($customer->getWebsiteId() != 0 && empty($defaultStoreId)) {
$storeIds = $this->storeManager->getWebsite($customer->getWebsiteId())->getStoreIds();
@@ -314,7 +317,7 @@ private function getWebsiteStoreId($customer, $defaultStoreId = null)
* @param CustomerInterface $customer
* @return void
*/
public function passwordReminder(CustomerInterface $customer)
public function passwordReminder(CustomerInterface $customer): void
{
$storeId = $customer->getStoreId();
if (!$storeId) {
@@ -338,7 +341,7 @@ public function passwordReminder(CustomerInterface $customer)
* @param CustomerInterface $customer
* @return void
*/
public function passwordResetConfirmation(CustomerInterface $customer)
public function passwordResetConfirmation(CustomerInterface $customer): void
{
$storeId = $customer->getStoreId();
if (!$storeId) {
@@ -373,7 +376,7 @@ public function newAccount(
$backUrl = '',
$storeId = 0,
$sendemailStoreId = null
) {
): void {
$types = self::TEMPLATE_TYPES;

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