11<?php
22/**
3- * Copyright © Magento, Inc. All rights reserved.
4- * See COPYING.txt for license details .
3+ * Copyright 2024 Adobe
4+ * All Rights Reserved .
55 */
66namespace Magento \Theme \Ui \Component \Design \Config ;
77
88use Magento \Framework \Api \FilterBuilder ;
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 /**
@@ -87,11 +96,38 @@ public function getData()
8796 ->create ()
8897 );
8998 }
99+
100+ $ themeConfigData = $ this ->getCoreConfigData ();
90101 $ data = parent ::getData ();
91102 foreach ($ data ['items ' ] as & $ item ) {
92103 $ item += ['default ' => __ ('Global ' )];
104+
105+ $ scope = ($ item ['store_id ' ]) ? 'stores ' : (($ item ['store_website_id ' ]) ? 'websites ' : 'default ' );
106+ $ scopeId = (int ) $ item ['store_website_id ' ] ?? 0 ;
107+ $ themeId = (int ) $ item ['theme_theme_id ' ] ?? 0 ;
108+
109+ $ criteria = ['scope ' => $ scope , 'scope_id ' => $ scopeId , 'value ' => $ themeId ];
110+ $ configData = array_filter ($ themeConfigData , function ($ themeConfig ) use ($ criteria ) {
111+ return array_intersect_assoc ($ criteria , $ themeConfig ) === $ criteria ;
112+ });
113+
114+ $ item += ['short_description ' => !$ configData ? __ ('Using Default Theme ' ) : '' ];
93115 }
94116
95117 return $ data ;
96118 }
119+
120+ /**
121+ * Get the core config data related to theme
122+ *
123+ * @return array
124+ */
125+ private function getCoreConfigData (): array
126+ {
127+ $ connection = $ this ->resourceConnection ->getConnection ();
128+ return $ connection ->fetchAll (
129+ $ connection ->select ()->from ($ connection ->getTableName ('core_config_data ' ))
130+ ->where ('path = ? ' , 'design/theme/theme_id ' )
131+ );
132+ }
97133}
0 commit comments