From 1d81f54c12b663be8802383f6c11d3d533dbfa01 Mon Sep 17 00:00:00 2001 From: Chirag Dodia Date: Fri, 30 Oct 2020 17:09:13 +0530 Subject: [PATCH 01/25] [WAGMODS-99] Removed deprecated methods and make code comapatible with latest class --- Controller/Index/AjaxPost.php | 35 ++++++++---- registration.php | 7 ++- view/frontend/templates/form/register.phtml | 59 +++++++++++---------- 3 files changed, 60 insertions(+), 41 deletions(-) diff --git a/Controller/Index/AjaxPost.php b/Controller/Index/AjaxPost.php index 8b499b5..ad266a2 100644 --- a/Controller/Index/AjaxPost.php +++ b/Controller/Index/AjaxPost.php @@ -15,8 +15,8 @@ namespace Wagento\HIBP\Controller\Index; use Dragonbe\Hibp\HibpFactory; -use Magento\Framework\App\Action\Action; -use Magento\Framework\App\Action\Context; +use Magento\Framework\App\Action\HttpPostActionInterface; +use Magento\Framework\App\RequestInterface; use Magento\Framework\Controller\ResultFactory; use Magento\Framework\Exception\NotFoundException; @@ -26,20 +26,35 @@ * @package Wagento\HIBP\Controller\Index * @author Joseph Leedy */ -class AjaxPost extends Action +class AjaxPost implements HttpPostActionInterface { /** - * @var \Dragonbe\Hibp\HibpFactory + * @var RequestInterface + */ + protected RequestInterface $request; + /** + * @var ResultFactory + */ + protected ResultFactory $resultFactory; + /** + * @var HibpFactory */ private $hibpFactory; + /** + * AjaxPost constructor. + * @param HibpFactory $hibpFactory + * @param RequestInterface $request + * @param ResultFactory $resultFactory + */ public function __construct( - Context $context, - HibpFactory $hibpFactory + HibpFactory $hibpFactory, + RequestInterface $request, + ResultFactory $resultFactory ) { - parent::__construct($context); - $this->hibpFactory = $hibpFactory; + $this->request = $request; + $this->resultFactory = $resultFactory; } /** @@ -47,12 +62,12 @@ public function __construct( */ public function execute() { - if (!$this->getRequest()->isAjax() || !$this->getRequest()->isPost()) { + if (!$this->request->isAjax() || !$this->request->isPost()) { throw new NotFoundException(__('Action is not available.')); } $hibp = $this->hibpFactory::create(); - $password = $this->getRequest()->getPost('password'); + $password = $this->request->getPost('password'); $resultJson = $this->resultFactory->create(ResultFactory::TYPE_JSON); $resultJson->setData([ diff --git a/registration.php b/registration.php index 69d7b85..ed9e548 100644 --- a/registration.php +++ b/registration.php @@ -9,8 +9,11 @@ * @copyright Copyright (c) Wagento Creative LLC. (https://www.wagento.com/) * @license https://opensource.org/licenses/OSL-3.0.php Open Software License 3.0 */ -\Magento\Framework\Component\ComponentRegistrar::register( - \Magento\Framework\Component\ComponentRegistrar::MODULE, + +use Magento\Framework\Component\ComponentRegistrar; + +ComponentRegistrar::register( + ComponentRegistrar::MODULE, 'Wagento_HIBP', __DIR__ ); diff --git a/view/frontend/templates/form/register.phtml b/view/frontend/templates/form/register.phtml index 39627d2..ddadf7a 100644 --- a/view/frontend/templates/form/register.phtml +++ b/view/frontend/templates/form/register.phtml @@ -7,21 +7,22 @@ // @codingStandardsIgnoreFile /** @var \Magento\Customer\Block\Form\Register $block */ +/** @var \Magento\Framework\Escaper $escaper */ ?> getChildHtml('form_fields_before') ?> getChildHtml('customer.form.register.extra') ?> -