From 775656da1842e5493f8fc8e460a95e628b112707 Mon Sep 17 00:00:00 2001 From: tuyennn Date: Fri, 28 Feb 2020 19:55:29 +0700 Subject: [PATCH 1/2] [TASK] PSR-2 Coding Standard --- Block/Initialize.php | 4 ++-- Block/QuickViewButton.php | 8 +++----- Model/Config.php | 2 +- Model/Renderer.php | 2 -- Observer/AddUpdateHandlesObserver.php | 7 +++---- Plugin/CartAddPlugin.php | 5 +---- Plugin/Catalog/Product/ListProductPlugin.php | 1 + Plugin/ResultPagePlugin.php | 9 ++++----- view/base/templates/button.phtml | 2 +- view/base/web/js/initQuickView.js | 4 ++-- 10 files changed, 18 insertions(+), 26 deletions(-) diff --git a/Block/Initialize.php b/Block/Initialize.php index 3818df7..5b82e75 100644 --- a/Block/Initialize.php +++ b/Block/Initialize.php @@ -2,10 +2,10 @@ namespace GhoSter\Quickview\Block; -use Magento\Framework\View\Element\Template\Context; -use Magento\Framework\Exception\NoSuchEntityException; use GhoSter\Quickview\Model\Config as QuickViewConfig; +use Magento\Framework\Exception\NoSuchEntityException; use Magento\Framework\View\Element\Template; +use Magento\Framework\View\Element\Template\Context; /** * Class Initialize block init the js diff --git a/Block/QuickViewButton.php b/Block/QuickViewButton.php index 2e1dc4b..b57e150 100644 --- a/Block/QuickViewButton.php +++ b/Block/QuickViewButton.php @@ -2,14 +2,14 @@ namespace GhoSter\Quickview\Block; +use GhoSter\Quickview\Model\Config; use Magento\Catalog\Model\Product; use Magento\Customer\Model\Context as CustomerContext; use Magento\Framework\App\Http\Context as HttpContext; -use Magento\Framework\View\Element\Template\Context; use Magento\Framework\DataObject\IdentityInterface; -use Magento\Framework\View\Element\Template; use Magento\Framework\Json\EncoderInterface; -use GhoSter\Quickview\Model\Config; +use Magento\Framework\View\Element\Template; +use Magento\Framework\View\Element\Template\Context; /** * Class QuickViewButton for rendering the button @@ -70,7 +70,6 @@ public function __construct( ]); } - /** * @return string */ @@ -101,7 +100,6 @@ public function isAdminArea() /** * @return array - * @throws \Magento\Framework\Exception\NoSuchEntityException */ public function getCacheKeyInfo() { diff --git a/Model/Config.php b/Model/Config.php index 7425f9f..2424dd1 100644 --- a/Model/Config.php +++ b/Model/Config.php @@ -3,9 +3,9 @@ namespace GhoSter\Quickview\Model; use Magento\Framework\App\Config\ScopeConfigInterface; -use Magento\Store\Model\StoreManagerInterface; use Magento\Store\Model\ScopeInterface; use Magento\Store\Model\Store; +use Magento\Store\Model\StoreManagerInterface; /** * Class Config provide configurations diff --git a/Model/Renderer.php b/Model/Renderer.php index 8d1d872..5cf539f 100644 --- a/Model/Renderer.php +++ b/Model/Renderer.php @@ -47,13 +47,11 @@ public function renderProductQuickViewButton(Product $product, $mode = self::MOD return $html; } - private function generateHtml(Product $product) { if ($this->buttonBlock === null) { $this->buttonBlock = $this->layout->createBlock(QuickViewButton::class); } - return $this->buttonBlock->setProduct($product)->toHtml(); } } diff --git a/Observer/AddUpdateHandlesObserver.php b/Observer/AddUpdateHandlesObserver.php index 99653b1..08d0ff5 100644 --- a/Observer/AddUpdateHandlesObserver.php +++ b/Observer/AddUpdateHandlesObserver.php @@ -2,13 +2,13 @@ namespace GhoSter\Quickview\Observer; -use Magento\Framework\Event\ObserverInterface; use Magento\Catalog\Api\ProductRepositoryInterface; -use Magento\Framework\Exception\NoSuchEntityException; use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\App\Request\Http as HttpRequest; -use Magento\Store\Model\StoreManagerInterface; use Magento\Framework\Event\Observer; +use Magento\Framework\Event\ObserverInterface; +use Magento\Framework\Exception\NoSuchEntityException; +use Magento\Store\Model\StoreManagerInterface; /** * Class AddUpdateHandlesObserver add handles types @@ -71,7 +71,6 @@ public function execute(Observer $observer) } $layout->getUpdate()->addHandle('ghoster_quickview_catalog_product_view_type_' . $product->getTypeId()); - } return $this; diff --git a/Plugin/CartAddPlugin.php b/Plugin/CartAddPlugin.php index 8c93111..40e7d60 100644 --- a/Plugin/CartAddPlugin.php +++ b/Plugin/CartAddPlugin.php @@ -36,7 +36,7 @@ public function __construct( * @return mixed */ public function afterExecute( - \Magento\Checkout\Controller\Cart\Add $subject, + Add $subject, $result ) { @@ -45,9 +45,6 @@ public function afterExecute( if (strpos($refererUrl, 'ghoster_quickview/catalog_product/view') !== false) { return $subject->getResponse()->representJson($this->jsonEncoder->encode([])); } - return $result; } - - } diff --git a/Plugin/Catalog/Product/ListProductPlugin.php b/Plugin/Catalog/Product/ListProductPlugin.php index 139e028..1a8eeaa 100644 --- a/Plugin/Catalog/Product/ListProductPlugin.php +++ b/Plugin/Catalog/Product/ListProductPlugin.php @@ -33,6 +33,7 @@ public function __construct( * @param $subject * @param $result * @return string + * @noinspection PhpUndefinedMethodInspection */ public function afterToHtml( $subject, diff --git a/Plugin/ResultPagePlugin.php b/Plugin/ResultPagePlugin.php index dabd232..f27344e 100644 --- a/Plugin/ResultPagePlugin.php +++ b/Plugin/ResultPagePlugin.php @@ -2,9 +2,9 @@ namespace GhoSter\Quickview\Plugin; -use Magento\Framework\View\Result\Page; use Magento\Framework\App\Request\Http as HttpRequest; use Magento\Framework\View\Layout; +use Magento\Framework\View\Result\Page; /** * Class ResultPagePlugin adding the default catalog_product_view @@ -39,15 +39,14 @@ public function __construct( * @return array */ public function beforeAddPageLayoutHandles( - \Magento\Framework\View\Result\Page $subject, + Page $subject, array $parameters = [], $defaultHandle = null ) { if ($this->request->getFullActionName() == 'ghoster_quickview_catalog_product_view') { return [$parameters, 'catalog_product_view']; - } else { - return [$parameters, $defaultHandle]; } - } + return [$parameters, $defaultHandle]; + } } diff --git a/view/base/templates/button.phtml b/view/base/templates/button.phtml index b12c2f8..53185cd 100644 --- a/view/base/templates/button.phtml +++ b/view/base/templates/button.phtml @@ -1,6 +1,6 @@ getProduct(); diff --git a/view/base/web/js/initQuickView.js b/view/base/web/js/initQuickView.js index 6f9f94e..0846371 100644 --- a/view/base/web/js/initQuickView.js +++ b/view/base/web/js/initQuickView.js @@ -53,8 +53,8 @@ define([ observer = new IntersectionObserver(function (entries) { if (entries[0].isIntersecting) { - self.execQuickView(); - observer.disconnect(); + self.execQuickView(); + observer.disconnect(); } }); From 266f65b6671a96c817a72b12a5d15062ba061844 Mon Sep 17 00:00:00 2001 From: tuyennn Date: Fri, 28 Feb 2020 19:59:01 +0700 Subject: [PATCH 2/2] [TASK] Update README --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index caba89d..492c477 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,9 @@ This Magento 2 extension provides quick view button, popup view the product from product list, widget. [![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) -[![Codacy Badge](https://api.codacy.com/project/badge/Grade/bf0757d0063e489eb3bff2479964fce2)](https://www.codacy.com/app/GhoSterInc/AutoInstagramPost?utm_source=github.com&utm_medium=referral&utm_content=tuyennn/AutoInstagramPost&utm_campaign=Badge_Grade) +[![Codacy Badge](https://api.codacy.com/project/badge/Grade/a0c2c8faab694998abc3c90ad3e7cc98)](https://www.codacy.com/manual/GhoSterInc/ProductQuickView?utm_source=github.com&utm_medium=referral&utm_content=tuyennn/ProductQuickView&utm_campaign=Badge_Grade) [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.me/thinghost) -[![Build Status](https://travis-ci.org/tuyennn/ProductQuickView.svg?branch=master)](https://travis-ci.org/tuyennn/AutoInstagramPost) +[![Build Status](https://travis-ci.org/tuyennn/ProductQuickView.svg?branch=master)](https://travis-ci.org/tuyennn/ProductQuickView) ![Version 1.0.0](https://img.shields.io/badge/Version-1.0.0-green.svg) ---