Skip to content

Commit

Permalink
ENGCOM-7282: Fix hard-code scope store string #26926
Browse files Browse the repository at this point in the history
  • Loading branch information
slavvka authored Apr 9, 2020
2 parents 42e615f + bf015b7 commit 587ecb4
Show file tree
Hide file tree
Showing 2 changed files with 259 additions and 174 deletions.
33 changes: 18 additions & 15 deletions app/code/Magento/Customer/Model/EmailNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Customer\Model;

Expand All @@ -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
Expand Down Expand Up @@ -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);
}

/**
Expand All @@ -139,7 +142,7 @@ public function credentialsChanged(
CustomerInterface $savedCustomer,
$origCustomerEmail,
$isPasswordChanged = false
) {
): void {
if ($origCustomerEmail != $savedCustomer->getEmail()) {
if ($isPasswordChanged) {
$this->emailAndPasswordChanged($savedCustomer, $origCustomerEmail);
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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
);

Expand All @@ -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;
Expand All @@ -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();
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -373,7 +376,7 @@ public function newAccount(
$backUrl = '',
$storeId = 0,
$sendemailStoreId = null
) {
): void {
$types = self::TEMPLATE_TYPES;

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

0 comments on commit 587ecb4

Please sign in to comment.