Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix type hints and replace deprecated method usage #21536

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions app/code/Magento/Newsletter/Controller/Subscriber/Confirm.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Confirm extends \Magento\Newsletter\Controller\Subscriber
{
/**
* Subscription confirm action
* @return void
* @return \Magento\Framework\Controller\Result\Redirect
*/
public function execute()
{
Expand All @@ -23,17 +23,17 @@ public function execute()

if ($subscriber->getId() && $subscriber->getCode()) {
if ($subscriber->confirm($code)) {
$this->messageManager->addSuccess(__('Your subscription has been confirmed.'));
$this->messageManager->addSuccessMessage(__('Your subscription has been confirmed.'));
} else {
$this->messageManager->addError(__('This is an invalid subscription confirmation code.'));
$this->messageManager->addErrorMessage(__('This is an invalid subscription confirmation code.'));
}
} else {
$this->messageManager->addError(__('This is an invalid subscription ID.'));
$this->messageManager->addErrorMessage(__('This is an invalid subscription ID.'));
}
}

$resultRedirect = $this->resultRedirectFactory->create();
$resultRedirect->setUrl($this->_storeManager->getStore()->getBaseUrl());
return $resultRedirect;
/** @var \Magento\Framework\Controller\Result\Redirect $redirect */
$redirect = $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT);
$redirectUrl = $this->_storeManager->getStore()->getBaseUrl();
return $redirect->setUrl($redirectUrl);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ protected function validateEmailFormat($email)
/**
* New subscription action
*
* @return void
* @return \Magento\Framework\Controller\Result\Redirect
*/
public function execute()
{
Expand Down Expand Up @@ -160,7 +160,10 @@ public function execute()
$this->messageManager->addExceptionMessage($e, __('Something went wrong with the subscription.'));
}
}
$this->getResponse()->setRedirect($this->_redirect->getRedirectUrl());
/** @var \Magento\Framework\Controller\Result\Redirect $redirect */
$redirect = $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT);
$redirectUrl = $this->_redirect->getRedirectUrl();
return $redirect->setUrl($redirectUrl);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Unsubscribe extends \Magento\Newsletter\Controller\Subscriber implements H
/**
* Unsubscribe newsletter.
*
* @return \Magento\Backend\Model\View\Result\Redirect
* @return \Magento\Framework\Controller\Result\Redirect
*/
public function execute()
{
Expand All @@ -25,14 +25,14 @@ public function execute()
if ($id && $code) {
try {
$this->_subscriberFactory->create()->load($id)->setCheckCode($code)->unsubscribe();
$this->messageManager->addSuccess(__('You unsubscribed.'));
$this->messageManager->addSuccessMessage(__('You unsubscribed.'));
} catch (\Magento\Framework\Exception\LocalizedException $e) {
$this->messageManager->addException($e, $e->getMessage());
$this->messageManager->addErrorMessage($e, $e->getMessage());
} catch (\Exception $e) {
$this->messageManager->addException($e, __('Something went wrong while unsubscribing you.'));
$this->messageManager->addErrorMessage($e, __('Something went wrong while unsubscribing you.'));
}
}
/** @var \Magento\Backend\Model\View\Result\Redirect $redirect */
/** @var \Magento\Framework\Controller\Result\Redirect $redirect */
$redirect = $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT);
$redirectUrl = $this->_redirect->getRedirectUrl();
return $redirect->setUrl($redirectUrl);
Expand Down