本文整理汇总了PHP中Magento\Customer\Api\AccountManagementInterface::resendConfirmation方法的典型用法代码示例。如果您正苦于以下问题:PHP AccountManagementInterface::resendConfirmation方法的具体用法?PHP AccountManagementInterface::resendConfirmation怎么用?PHP AccountManagementInterface::resendConfirmation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Customer\Api\AccountManagementInterface
的用法示例。
在下文中一共展示了AccountManagementInterface::resendConfirmation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* Send confirmation link to specified email
*
* @return \Magento\Framework\Controller\Result\Redirect|\Magento\Framework\View\Result\Page
*/
public function execute()
{
if ($this->session->isLoggedIn()) {
/** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
$resultRedirect = $this->resultRedirectFactory->create();
$resultRedirect->setPath('*/*/');
return $resultRedirect;
}
// try to confirm by email
$email = $this->getRequest()->getPost('email');
if ($email) {
/** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
$resultRedirect = $this->resultRedirectFactory->create();
try {
$this->customerAccountManagement->resendConfirmation($email, $this->storeManager->getStore()->getWebsiteId());
$this->messageManager->addSuccess(__('Please check your email for confirmation key.'));
} catch (InvalidTransitionException $e) {
$this->messageManager->addSuccess(__('This email does not require confirmation.'));
} catch (\Exception $e) {
$this->messageManager->addException($e, __('Wrong email.'));
$resultRedirect->setPath('*/*/*', ['email' => $email, '_secure' => true]);
return $resultRedirect;
}
$this->session->setUsername($email);
$resultRedirect->setPath('*/*/index', ['_secure' => true]);
return $resultRedirect;
}
/** @var \Magento\Framework\View\Result\Page $resultPage */
$resultPage = $this->resultPageFactory->create();
$resultPage->getLayout()->getBlock('accountConfirmation')->setEmail($this->getRequest()->getParam('email', $email));
return $resultPage;
}
示例2: testResendConfirmationNotNeeded
/**
* @magentoDataFixture Magento/Customer/_files/customer.php
* @expectedException \Magento\Framework\Exception\State\InvalidTransitionException
*/
public function testResendConfirmationNotNeeded()
{
$this->accountManagement->resendConfirmation('customer@example.com', 1);
}