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 all commits
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
27 changes: 17 additions & 10 deletions app/code/Magento/Newsletter/Controller/Subscriber/Confirm.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,20 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Newsletter\Controller\Subscriber;

class Confirm extends \Magento\Newsletter\Controller\Subscriber
use Magento\Framework\App\Action\HttpGetActionInterface;

/**
* Confirm subscription controller.
*/
class Confirm extends \Magento\Newsletter\Controller\Subscriber implements HttpGetActionInterface
{
/**
* Subscription confirm action
* @return void
* Subscription confirm action.
*
* @return \Magento\Framework\Controller\Result\Redirect
*/
public function execute()
{
Expand All @@ -23,17 +30,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 @@ -4,6 +4,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Newsletter\Controller\Subscriber;

use Magento\Customer\Api\AccountManagementInterface as CustomerAccountManagement;
Expand Down Expand Up @@ -131,7 +132,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 +161,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 @@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Newsletter\Controller\Subscriber;

use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
Expand All @@ -15,7 +16,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 +26,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