Skip to content

Commit ca4df43

Browse files
author
Volodymyr Kublytskyi
committed
Stabilization magento-partners/magento2ce#84
1 parent 8959639 commit ca4df43

File tree

2 files changed

+45
-20
lines changed

2 files changed

+45
-20
lines changed

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

Lines changed: 41 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,12 @@ private function activateCustomer($customer, $confirmationKey)
460460

461461
$customer->setConfirmation(null);
462462
$this->customerRepository->save($customer);
463-
$this->getEmailNotification()->newAccount($customer, 'confirmed', '', $this->storeManager->getStore()->getId());
463+
$this->getEmailNotification()->newAccount(
464+
$customer,
465+
'confirmed',
466+
'',
467+
$this->storeManager->getStore()->getId()
468+
);
464469
return $customer;
465470
}
466471

@@ -531,17 +536,8 @@ public function initiatePasswordReset($email, $template, $websiteId = null)
531536
$this->getEmailNotification()->passwordResetConfirmation($customer);
532537
break;
533538
default:
534-
throw new InputException(
535-
__(
536-
'Invalid value of "%value" provided for the %fieldName field. Possible values are %template1 or %template2.',
537-
[
538-
'value' => $template,
539-
'fieldName' => 'template',
540-
'template1' => AccountManagement::EMAIL_REMINDER,
541-
'template2' => AccountManagement::EMAIL_RESET
542-
]
543-
)
544-
);
539+
$this->handleUnknownTemplate($template);
540+
break;
545541
}
546542
return true;
547543
} catch (MailException $e) {
@@ -551,6 +547,25 @@ public function initiatePasswordReset($email, $template, $websiteId = null)
551547
return false;
552548
}
553549

550+
/**
551+
* Handle not supported template
552+
*
553+
* @param string $template
554+
* @throws InputException
555+
*/
556+
private function handleUnknownTemplate($template)
557+
{
558+
throw new InputException(__(
559+
'Invalid value of "%value" provided for the %fieldName field. Possible values: %template1 or %template2.',
560+
[
561+
'value' => $template,
562+
'fieldName' => 'template',
563+
'template1' => AccountManagement::EMAIL_REMINDER,
564+
'template2' => AccountManagement::EMAIL_RESET
565+
]
566+
));
567+
}
568+
554569
/**
555570
* {@inheritdoc}
556571
*/
@@ -1116,15 +1131,23 @@ protected function sendEmailTemplate(
11161131
$storeId = null,
11171132
$email = null
11181133
) {
1119-
$templateId = $this->scopeConfig->getValue($template, ScopeInterface::SCOPE_STORE, $storeId);
1134+
$templateId = $this->scopeConfig->getValue(
1135+
$template,
1136+
ScopeInterface::SCOPE_STORE,
1137+
$storeId
1138+
);
11201139
if ($email === null) {
11211140
$email = $customer->getEmail();
11221141
}
11231142

11241143
$transport = $this->transportBuilder->setTemplateIdentifier($templateId)
11251144
->setTemplateOptions(['area' => Area::AREA_FRONTEND, 'store' => $storeId])
11261145
->setTemplateVars($templateParams)
1127-
->setFrom($this->scopeConfig->getValue($sender, ScopeInterface::SCOPE_STORE, $storeId))
1146+
->setFrom($this->scopeConfig->getValue(
1147+
$sender,
1148+
ScopeInterface::SCOPE_STORE,
1149+
$storeId
1150+
))
11281151
->addTo($email, $this->customerViewHelper->getCustomerName($customer))
11291152
->getTransport();
11301153

@@ -1318,8 +1341,10 @@ protected function getFullCustomerObject($customer)
13181341
// No need to flatten the custom attributes or nested objects since the only usage is for email templates and
13191342
// object passed for events
13201343
$mergedCustomerData = $this->customerRegistry->retrieveSecureData($customer->getId());
1321-
$customerData =
1322-
$this->dataProcessor->buildOutputDataArray($customer, \Magento\Customer\Api\Data\CustomerInterface::class);
1344+
$customerData = $this->dataProcessor->buildOutputDataArray(
1345+
$customer,
1346+
\Magento\Customer\Api\Data\CustomerInterface::class
1347+
);
13231348
$mergedCustomerData->addData($customerData);
13241349
$mergedCustomerData->setData('name', $this->customerViewHelper->getCustomerName($customer));
13251350
return $mergedCustomerData;

app/code/Magento/Customer/Test/Unit/Model/AccountManagementTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,10 +1173,6 @@ public function testInitiatePasswordResetEmailReset()
11731173
$this->assertTrue($this->accountManagement->initiatePasswordReset($email, $template));
11741174
}
11751175

1176-
/**
1177-
* @expectedException \Magento\Framework\Exception\InputException
1178-
* @expectedExceptionMessage Invalid value of "" provided for the template field. Possible values are email_reminder or email_reset.
1179-
*/
11801176
public function testInitiatePasswordResetNoTemplate()
11811177
{
11821178
$storeId = 1;
@@ -1192,6 +1188,10 @@ public function testInitiatePasswordResetNoTemplate()
11921188

11931189
$this->prepareInitiatePasswordReset($email, $templateIdentifier, $sender, $storeId, $customerId, $hash);
11941190

1191+
$this->expectException(\Magento\Framework\Exception\InputException::class);
1192+
$this->expectExceptionMessage(
1193+
'Invalid value of "" provided for the template field. Possible values: email_reminder or email_reset.'
1194+
);
11951195
$this->accountManagement->initiatePasswordReset($email, $template);
11961196
}
11971197

0 commit comments

Comments
 (0)