From 15202f02e5ec18749dc9fe17674510cf50311bba Mon Sep 17 00:00:00 2001 From: chuccv Date: Wed, 14 Aug 2024 17:03:24 +0700 Subject: [PATCH 1/2] update(hyva): add check is Hyva in HelperData --- Helper/AbstractData.php | 47 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/Helper/AbstractData.php b/Helper/AbstractData.php index 6afce9b..fc366b7 100755 --- a/Helper/AbstractData.php +++ b/Helper/AbstractData.php @@ -29,9 +29,12 @@ use Magento\Framework\App\ObjectManager; use Magento\Framework\App\ProductMetadataInterface; use Magento\Framework\App\State; +use Magento\Framework\Exception\NoSuchEntityException; use Magento\Framework\Json\Helper\Data as JsonHelper; use Magento\Framework\ObjectManagerInterface; use Magento\Framework\UrlInterface; +use Magento\Framework\View\Design\Theme\ThemeProviderInterface; +use Magento\Framework\View\DesignInterface; use Magento\Store\Model\ScopeInterface; use Magento\Store\Model\StoreManagerInterface; use Mageplaza\Core\Model\Config\Source\NoticeType; @@ -373,7 +376,7 @@ public static function extractBody($response_str) /** * getHtmlJqColorPicker * - * @param string $htmlId // id of the input html + * @param string $htmlId // id of the input html * @param string|null $value * * @return string @@ -398,4 +401,46 @@ public static function getHtmlJqColorPicker(string $htmlId, $value = '') HTML; } + + /** + * Return is Hyva Theme + * + * @return bool + */ + public function checkHyvaTheme() + { + try { + $themeCode = $this->getThemeCodeByCache(); + } catch (\Exception $e) { + try { + /** @var ThemeProviderInterface $themeProviderInterface */ + $themeProviderInterface = $this->objectManager->create(ThemeProviderInterface::Class); + $themeId = $this->storeManager->getStore()->getConfig('design/theme/theme_id'); + $theme = $themeProviderInterface->getThemeById($themeId); + $themeCode = $theme->getCode(); + } catch (NoSuchEntityException $noSuchEntityException) { + return false; + } + } + + if (str_contains($themeCode, 'Hyva')) { + return true; + } + + return false; + } + + /** + * GetThemeCode By Cache in DesignInterface + * + * @return string + */ + private function getThemeCodeByCache() + { + /** @var DesignInterface $themeProviderInterface */ + $themeProviderInterface = $this->objectManager->create(DesignInterface::Class); + $theme = $themeProviderInterface->getDesignTheme(); + + return $theme->getCode(); + } } From e74f4e829cbe5256d0e13f59116887b23cf72d8d Mon Sep 17 00:00:00 2001 From: chuccv Date: Wed, 14 Aug 2024 17:07:30 +0700 Subject: [PATCH 2/2] Release v1.5.8 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 750913a..1b3b213 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "mageplaza/module-core", "description": "Mageplaza Core for Magento 2", "type": "magento2-module", - "version": "1.5.7", + "version": "1.5.8", "license": "proprietary", "authors": [ {