diff --git a/Block/Quicklink.php b/Block/Quicklink.php index 0862044..e49ab91 100644 --- a/Block/Quicklink.php +++ b/Block/Quicklink.php @@ -1,7 +1,7 @@ - * @copyright Copyright (c) 2020. + * @copyright Copyright (c) 2023. */ namespace Rafaelcg\Quicklink\Block; @@ -16,19 +16,11 @@ */ class Quicklink extends Template { + private Template\Context $context; - /** - * @var Template\Context - */ - private $context; - /** - * @var array - */ - private $data; - /** - * @var Data - */ - private $helper; + private array $data; + + private Data $helper; /** * Constructor @@ -56,7 +48,7 @@ public function __construct( * * @return array|string */ - public function initConfig() + public function initConfig(): array|string { $initConfig = []; $timeout = $this->helper->getTimeout(); @@ -80,24 +72,17 @@ public function initConfig() return $initConfig; } - protected function runInDeveloperMode() - { - return $this->helper->getRunInDeveloperMode(); - } - /** * Render GA tracking scripts * * @return string */ - protected function _toHtml() + protected function _toHtml(): string { $isProductionMode = $this->_appState->getMode() === State::MODE_PRODUCTION; $runInDeveloperMode = $this->helper->runInDeveloperMode(); - if (!$this->helper->isQuicklinkEnabled()) { - if (!$runInDeveloperMode && !$isProductionMode) { - return ''; - } + if (!$runInDeveloperMode && !$isProductionMode) { + return ''; } return parent::_toHtml(); } diff --git a/Model/Helper/Data.php b/Model/Helper/Data.php index fd5f419..9ae825e 100644 --- a/Model/Helper/Data.php +++ b/Model/Helper/Data.php @@ -1,7 +1,7 @@ - * @copyright Copyright (c) 2020. + * @copyright Copyright (c) 2023. */ namespace Rafaelcg\Quicklink\Model\Helper; @@ -32,7 +32,7 @@ class Data extends AbstractHelper * @param null $scopeCode * @return mixed */ - public function getConfig($path, $scopeCode = null) + public function getConfig($path, $scopeCode = null): mixed { $config = $this->scopeConfig->getValue($path, ScopeInterface::SCOPE_STORE, $scopeCode); return !empty($config) ? $config : false; @@ -43,7 +43,7 @@ public function getConfig($path, $scopeCode = null) * * @return int|mixed */ - public function getTimeout() + public function getTimeout(): mixed { return $this->getConfig(self::XML_PATH_TIMEOUT); } @@ -53,7 +53,7 @@ public function getTimeout() * * @return int|mixed */ - public function getRequestLimit() + public function getRequestLimit(): mixed { return $this->getConfig(self::XML_PATH_REQUEST_LIMIT); } @@ -63,7 +63,7 @@ public function getRequestLimit() * * @return int|mixed */ - public function getConcurrencyLimit() + public function getConcurrencyLimit(): mixed { return $this->getConfig(self::XML_PATH_CONCURRENCY_LIMIT); } @@ -73,7 +73,7 @@ public function getConcurrencyLimit() * * @return int|mixed */ - public function getPriority() + public function getPriority(): mixed { return $this->getConfig(self::XML_PATH_PRIORITY); } @@ -81,21 +81,22 @@ public function getPriority() /** * Whether Quicklink is ready to use * + * @deprecated 2.2.0 * @param null $store * @return bool */ - public function isQuicklinkEnabled($store = null) + public function isQuicklinkEnabled($store = null): bool { return $this->scopeConfig->isSetFlag(self::XML_PATH_ACTIVE, ScopeInterface::SCOPE_STORE, $store); } /** - * Check if can run in developer mode + * Check if you can run it in developer mode * * @param null $store * @return bool */ - public function runInDeveloperMode($store = null) + public function runInDeveloperMode($store = null): bool { return $this->scopeConfig->isSetFlag(self::XML_PATH_DEVELOPER_MODE, ScopeInterface::SCOPE_STORE, $store); } diff --git a/composer.json b/composer.json index 636f141..7f673f2 100755 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "rafaelcg/magento2-quicklink", "description": "Faster subsequent page-loads by prefetching in-viewport links during idle time", "homepage": "https://github.com/rafaelstz/magento2-quicklink", - "version": "2.2.0", + "version": "2.2.1", "require": { "php": "~7.4.0||~8.1.0", "magento/framework": "~103.0.0||~104.0.0" diff --git a/etc/acl.xml b/etc/acl.xml index d93f237..ab3f1b2 100755 --- a/etc/acl.xml +++ b/etc/acl.xml @@ -1,7 +1,7 @@ diff --git a/etc/config.xml b/etc/config.xml index eb36a98..8caf5be 100755 --- a/etc/config.xml +++ b/etc/config.xml @@ -1,7 +1,7 @@ diff --git a/etc/csp_whitelist.xml b/etc/csp_whitelist.xml index 156d926..42c4b33 100644 --- a/etc/csp_whitelist.xml +++ b/etc/csp_whitelist.xml @@ -1,7 +1,7 @@ diff --git a/view/frontend/layout/default.xml b/view/frontend/layout/default.xml index 32693ce..10fdfda 100755 --- a/view/frontend/layout/default.xml +++ b/view/frontend/layout/default.xml @@ -1,13 +1,14 @@ - + template="Rafaelcg_Quicklink::quicklink.phtml" ifconfig="quicklink/general/active"> Rafaelcg\Quicklink\ViewModel\Quicklink diff --git a/view/frontend/requirejs-config.js b/view/frontend/requirejs-config.js index d3ea04c..7282e05 100755 --- a/view/frontend/requirejs-config.js +++ b/view/frontend/requirejs-config.js @@ -1,6 +1,6 @@ /* * @author Rafael Corrêa Gomes - * @copyright Copyright (c) 2020. + * @copyright Copyright (c) 2023. */ var config = {