17
17
use Magento \Store \Model \StoreManagerInterface ;
18
18
use Magento \Framework \View \Design \Theme \ThemeProviderInterface ;
19
19
use Magefan \Blog \Model \Config ;
20
+ use Magefan \Community \Model \HyvaThemeDetection ;
21
+
20
22
class HyvaThemeChecker extends Template
21
23
{
22
24
/**
@@ -39,6 +41,11 @@ class HyvaThemeChecker extends Template
39
41
*/
40
42
protected $ themeProvider ;
41
43
44
+ /**
45
+ * @var HyvaThemeDetection
46
+ */
47
+ protected $ hyvaThemeDetection ;
48
+
42
49
/**
43
50
* @var Config
44
51
*/
@@ -62,13 +69,15 @@ public function __construct(
62
69
ScopeConfigInterface $ scopeConfig ,
63
70
ThemeProviderInterface $ themeProvider ,
64
71
Config $ config ,
72
+ HyvaThemeDetection $ hyvaThemeDetection ,
65
73
array $ data = []
66
74
) {
67
75
parent ::__construct ($ context , $ data );
68
76
$ this ->moduleManager = $ moduleManager ;
69
77
$ this ->storeManager = $ storeManager ;
70
78
$ this ->scopeConfig = $ scopeConfig ;
71
79
$ this ->themeProvider = $ themeProvider ;
80
+ $ this ->hyvaThemeDetection =$ hyvaThemeDetection ;
72
81
$ this ->config = $ config ;
73
82
}
74
83
@@ -101,37 +110,6 @@ public function getWitchModuleIsInstalled(): array
101
110
return $ hyvaModules ;
102
111
}
103
112
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
-
135
113
/**
136
114
* Produce and return block's html output
137
115
*
@@ -142,7 +120,7 @@ private function isHyvaThemeInUse(): bool
142
120
public function toHtml ()
143
121
{
144
122
if ($ this ->config ->isEnabled ()){
145
- if (!$ this ->isHyvaThemeInUse ()) {
123
+ if (!$ this ->hyvaThemeDetection -> execute ()) {
146
124
return '' ;
147
125
}
148
126
0 commit comments