Skip to content

Commit b2bf199

Browse files
committed
moved function to module community
1 parent f52d3a2 commit b2bf199

File tree

1 file changed

+10
-32
lines changed

1 file changed

+10
-32
lines changed

Block/Adminhtml/HyvaThemeChecker.php

Lines changed: 10 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
use Magento\Store\Model\StoreManagerInterface;
1818
use Magento\Framework\View\Design\Theme\ThemeProviderInterface;
1919
use Magefan\Blog\Model\Config;
20+
use Magefan\Community\Model\HyvaThemeDetection;
21+
2022
class HyvaThemeChecker extends Template
2123
{
2224
/**
@@ -39,6 +41,11 @@ class HyvaThemeChecker extends Template
3941
*/
4042
protected $themeProvider;
4143

44+
/**
45+
* @var HyvaThemeDetection
46+
*/
47+
protected $hyvaThemeDetection;
48+
4249
/**
4350
* @var Config
4451
*/
@@ -62,13 +69,15 @@ public function __construct(
6269
ScopeConfigInterface $scopeConfig,
6370
ThemeProviderInterface $themeProvider,
6471
Config $config,
72+
HyvaThemeDetection $hyvaThemeDetection,
6573
array $data = []
6674
) {
6775
parent::__construct($context, $data);
6876
$this->moduleManager = $moduleManager;
6977
$this->storeManager = $storeManager;
7078
$this->scopeConfig = $scopeConfig;
7179
$this->themeProvider = $themeProvider;
80+
$this->hyvaThemeDetection =$hyvaThemeDetection;
7281
$this->config = $config;
7382
}
7483

@@ -101,37 +110,6 @@ public function getWitchModuleIsInstalled(): array
101110
return $hyvaModules;
102111
}
103112

104-
/**
105-
* @return bool
106-
*/
107-
private function isHyvaThemeInUse(): bool
108-
{
109-
$hyvaThemeEnabled = $this->moduleManager->isEnabled('Hyva_Theme');
110-
// $hyvaThemeEnabled = true;
111-
if ($hyvaThemeEnabled) {
112-
$stores = $this->storeManager->getStores();
113-
114-
foreach ($stores as $store) {
115-
$storeId = $store->getId();
116-
$themeId = $this->scopeConfig->getValue(
117-
\Magento\Framework\View\DesignInterface::XML_PATH_THEME_ID,
118-
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
119-
$storeId
120-
);
121-
if ($themeId) {
122-
$theme = $this->themeProvider->getThemeById($themeId);
123-
$theme->getThemePath();
124-
$themePath = $theme->getThemePath();
125-
if (false !== stripos($themePath, 'hyva')) {
126-
return true;
127-
}
128-
}
129-
}
130-
}
131-
132-
return false;
133-
}
134-
135113
/**
136114
* Produce and return block's html output
137115
*
@@ -142,7 +120,7 @@ private function isHyvaThemeInUse(): bool
142120
public function toHtml()
143121
{
144122
if ($this->config->isEnabled()){
145-
if (!$this->isHyvaThemeInUse()) {
123+
if (!$this->hyvaThemeDetection->execute()) {
146124
return '';
147125
}
148126

0 commit comments

Comments
 (0)