Skip to content

Commit ce61689

Browse files
authored
Extract customer deletion into method
1 parent c694e9c commit ce61689

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

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

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -967,14 +967,7 @@ public function createAccountWithPasswordHash(CustomerInterface $customer, $hash
967967
}
968968
$this->customerRegistry->remove($customer->getId());
969969
} catch (InputException $e) {
970-
$originalValue = $this->registry->registry('isSecureArea');
971-
$this->registry->unregister('isSecureArea');
972-
$this->registry->register('isSecureArea', true);
973-
974-
$this->customerRepository->delete($customer);
975-
976-
$this->registry->unregister('isSecureArea');
977-
$this->registry->register('isSecureArea', $originalValue);
970+
$this->deleteCustomerInSecureArea($customer);
978971

979972
throw $e;
980973
}
@@ -1686,4 +1679,16 @@ private function isAddressAllowedForWebsite(AddressInterface $address, $storeId)
16861679

16871680
return in_array($address->getCountryId(), $allowedCountries);
16881681
}
1682+
1683+
private function deleteCustomerInSecureArea(CustomerInterface $customer): void
1684+
{
1685+
$originalValue = $this->registry->registry('isSecureArea');
1686+
$this->registry->unregister('isSecureArea');
1687+
$this->registry->register('isSecureArea', true);
1688+
1689+
$this->customerRepository->delete($customer);
1690+
1691+
$this->registry->unregister('isSecureArea');
1692+
$this->registry->register('isSecureArea', $originalValue);
1693+
}
16891694
}

0 commit comments

Comments
 (0)