9
9
use Magento \Framework \Api \Search \ReportingInterface ;
10
10
use Magento \Framework \Api \Search \SearchCriteriaBuilder ;
11
11
use Magento \Framework \App \RequestInterface ;
12
+ use Magento \Framework \App \ResourceConnection ;
12
13
use Magento \Store \Model \StoreManagerInterface ;
13
14
14
15
/**
@@ -25,6 +26,11 @@ class DataProvider extends \Magento\Framework\View\Element\UiComponent\DataProvi
25
26
*/
26
27
protected $ storeManager ;
27
28
29
+ /**
30
+ * @var ResourceConnection
31
+ */
32
+ private $ resourceConnection ;
33
+
28
34
/**
29
35
* @param string $name
30
36
* @param string $primaryFieldName
@@ -34,6 +40,7 @@ class DataProvider extends \Magento\Framework\View\Element\UiComponent\DataProvi
34
40
* @param RequestInterface $request
35
41
* @param FilterBuilder $filterBuilder
36
42
* @param StoreManagerInterface $storeManager
43
+ * @param ResourceConnection $resourceConnection
37
44
* @param array $meta
38
45
* @param array $data
39
46
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
@@ -47,6 +54,7 @@ public function __construct(
47
54
RequestInterface $ request ,
48
55
FilterBuilder $ filterBuilder ,
49
56
StoreManagerInterface $ storeManager ,
57
+ ResourceConnection $ resourceConnection ,
50
58
array $ meta = [],
51
59
array $ data = []
52
60
) {
@@ -62,6 +70,7 @@ public function __construct(
62
70
$ data
63
71
);
64
72
$ this ->storeManager = $ storeManager ;
73
+ $ this ->resourceConnection = $ resourceConnection ;
65
74
}
66
75
67
76
/**
@@ -90,8 +99,37 @@ public function getData()
90
99
$ data = parent ::getData ();
91
100
foreach ($ data ['items ' ] as & $ item ) {
92
101
$ item += ['default ' => __ ('Global ' )];
102
+
103
+ $ scope = ($ item ['store_id ' ]) ? 'stores ' : (($ item ['store_website_id ' ]) ? 'websites ' : 'default ' );
104
+ $ scopeId = (int ) $ item ['store_website_id ' ] ?? 0 ;
105
+ $ themeId = (int ) $ item ['theme_theme_id ' ] ?? 0 ;
106
+ $ usingDefaultTheme = $ this ->isUsingDefaultTheme ($ scopeId , $ themeId , $ scope );
107
+ $ item += ['short_description ' => $ usingDefaultTheme ? __ ('Using Default Theme ' ) : '' ];
93
108
}
94
109
95
110
return $ data ;
96
111
}
112
+
113
+ /**
114
+ * Check if theme used is default theme
115
+ *
116
+ * @param int $scopeId
117
+ * @param int $themeId
118
+ * @param string $scope
119
+ * @return bool
120
+ */
121
+ private function isUsingDefaultTheme (int $ scopeId , int $ themeId , string $ scope ): bool
122
+ {
123
+ $ connection = $ this ->resourceConnection ->getConnection ();
124
+ $ configId = $ connection ->fetchOne (
125
+ $ connection ->select ()->from (
126
+ $ connection ->getTableName ('core_config_data ' ),
127
+ ['config_id ' ]
128
+ )->where ('value = ? ' , $ themeId )
129
+ ->where ('scope_id = ? ' , $ scopeId )
130
+ ->where ('path = ? ' , 'design/theme/theme_id ' )
131
+ ->where ('scope = ? ' , $ scope )
132
+ );
133
+ return !$ configId ;
134
+ }
97
135
}
0 commit comments