99use Magento \Framework \Api \Search \ReportingInterface ;
1010use Magento \Framework \Api \Search \SearchCriteriaBuilder ;
1111use Magento \Framework \App \RequestInterface ;
12+ use Magento \Framework \App \ResourceConnection ;
1213use Magento \Store \Model \StoreManagerInterface ;
1314
1415/**
@@ -25,6 +26,11 @@ class DataProvider extends \Magento\Framework\View\Element\UiComponent\DataProvi
2526 */
2627 protected $ storeManager ;
2728
29+ /**
30+ * @var ResourceConnection
31+ */
32+ private $ resourceConnection ;
33+
2834 /**
2935 * @param string $name
3036 * @param string $primaryFieldName
@@ -34,6 +40,7 @@ class DataProvider extends \Magento\Framework\View\Element\UiComponent\DataProvi
3440 * @param RequestInterface $request
3541 * @param FilterBuilder $filterBuilder
3642 * @param StoreManagerInterface $storeManager
43+ * @param ResourceConnection $resourceConnection
3744 * @param array $meta
3845 * @param array $data
3946 * @SuppressWarnings(PHPMD.ExcessiveParameterList)
@@ -47,6 +54,7 @@ public function __construct(
4754 RequestInterface $ request ,
4855 FilterBuilder $ filterBuilder ,
4956 StoreManagerInterface $ storeManager ,
57+ ResourceConnection $ resourceConnection ,
5058 array $ meta = [],
5159 array $ data = []
5260 ) {
@@ -62,6 +70,7 @@ public function __construct(
6270 $ data
6371 );
6472 $ this ->storeManager = $ storeManager ;
73+ $ this ->resourceConnection = $ resourceConnection ;
6574 }
6675
6776 /**
@@ -90,8 +99,37 @@ public function getData()
9099 $ data = parent ::getData ();
91100 foreach ($ data ['items ' ] as & $ item ) {
92101 $ 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 ' ) : '' ];
93108 }
94109
95110 return $ data ;
96111 }
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+ }
97135}
0 commit comments