Skip to content

Commit 895abb8

Browse files
authored
AC-2257: Fix logging level
1 parent 000678b commit 895abb8

File tree

1 file changed

+29
-25
lines changed

1 file changed

+29
-25
lines changed

app/code/Magento/Customer/Controller/Account/Confirmation.php

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,26 @@
1515
use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;
1616
use Magento\Framework\App\Action\Context;
1717
use Magento\Framework\App\ObjectManager;
18+
use Magento\Framework\Controller\Result\Redirect;
19+
use Magento\Framework\Exception\LocalizedException;
1820
use Magento\Framework\Exception\NoSuchEntityException;
1921
use Magento\Framework\Exception\State\InvalidTransitionException;
22+
use Magento\Framework\View\Result\Page;
2023
use Magento\Framework\View\Result\PageFactory;
2124
use Magento\Store\Model\StoreManagerInterface;
2225

2326
/**
24-
* Class Confirmation. Send confirmation link to specified email
27+
* Send confirmation link to specified email
2528
*/
2629
class Confirmation extends AbstractAccount implements HttpGetActionInterface, HttpPostActionInterface
2730
{
2831
/**
29-
* @var \Magento\Store\Model\StoreManagerInterface
32+
* @var StoreManagerInterface
3033
*/
3134
protected $storeManager;
3235

3336
/**
34-
* @var \Magento\Customer\Api\AccountManagementInterface
37+
* @var AccountManagementInterface
3538
*/
3639
protected $customerAccountManagement;
3740

@@ -56,7 +59,7 @@ class Confirmation extends AbstractAccount implements HttpGetActionInterface, Ht
5659
* @param PageFactory $resultPageFactory
5760
* @param StoreManagerInterface $storeManager
5861
* @param AccountManagementInterface $customerAccountManagement
59-
* @param Url $customerUrl
62+
* @param Url|null $customerUrl
6063
*/
6164
public function __construct(
6265
Context $context,
@@ -77,51 +80,52 @@ public function __construct(
7780
/**
7881
* Send confirmation link to specified email
7982
*
80-
* @return \Magento\Framework\Controller\Result\Redirect|\Magento\Framework\View\Result\Page
83+
* @return Redirect|Page
84+
* @throws LocalizedException
8185
*/
8286
public function execute()
8387
{
8488
if ($this->session->isLoggedIn()) {
85-
/** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
86-
$resultRedirect = $this->resultRedirectFactory->create();
87-
$resultRedirect->setPath('*/*/');
88-
return $resultRedirect;
89+
return $this->getRedirect('*/*/');
8990
}
9091

91-
// try to confirm by email
9292
$email = $this->getRequest()->getPost('email');
93-
if ($email) {
94-
/** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
95-
$resultRedirect = $this->resultRedirectFactory->create();
9693

94+
if ($email) {
9795
try {
9896
$this->customerAccountManagement->resendConfirmation(
9997
$email,
10098
$this->storeManager->getStore()->getWebsiteId()
10199
);
102100
$this->messageManager->addSuccessMessage(__('Please check your email for confirmation key.'));
103-
$this->session->setUsername($email);
104-
$resultRedirect->setPath('*/*/index', ['_secure' => true]);
105-
106-
return $resultRedirect;
101+
return $this->getRedirect('*/*/index', ['_secure' => true]);
107102
} catch (InvalidTransitionException $e) {
108103
$this->messageManager->addSuccessMessage(__('This email does not require confirmation.'));
109-
$this->session->setUsername($email);
110-
$resultRedirect->setPath('*/*/index', ['_secure' => true]);
111-
112-
return $resultRedirect;
104+
return $this->getRedirect('*/*/index', ['_secure' => true]);
113105
} catch (NoSuchEntityException $e) {
114106
$this->messageManager->addErrorMessage(__('Wrong email.'));
115107
}
116108
}
117109

118-
/** @var \Magento\Framework\View\Result\Page $resultPage */
119110
$resultPage = $this->resultPageFactory->create();
120-
$resultPage->getLayout()
121-
->getBlock('accountConfirmation')
111+
$resultPage->getLayout()->getBlock('accountConfirmation')
122112
->setEmail($email)
123113
->setLoginUrl($this->customerUrl->getLoginUrl());
124-
125114
return $resultPage;
126115
}
116+
117+
/**
118+
* Returns redirect objects
119+
*
120+
* @param string $path
121+
* @param array $params
122+
* @return Redirect
123+
*/
124+
private function getRedirect(string $path, array $params = []): Redirect
125+
{
126+
$resultRedirect = $this->resultRedirectFactory->create();
127+
$resultRedirect->setPath($path, $params);
128+
129+
return $resultRedirect;
130+
}
127131
}

0 commit comments

Comments
 (0)