|
1 | 1 | <?php |
2 | 2 | /** |
3 | | - * Copyright © Magento, Inc. All rights reserved. |
4 | | - * See COPYING.txt for license details. |
| 3 | + * Copyright 2024 Adobe |
| 4 | + * All Rights Reserved. |
5 | 5 | */ |
6 | 6 | namespace Magento\Theme\Ui\Component\Design\Config; |
7 | 7 |
|
@@ -96,40 +96,38 @@ public function getData() |
96 | 96 | ->create() |
97 | 97 | ); |
98 | 98 | } |
| 99 | + |
| 100 | + $themeConfigData = $this->getCoreConfigData(); |
99 | 101 | $data = parent::getData(); |
100 | 102 | foreach ($data['items'] as & $item) { |
101 | 103 | $item += ['default' => __('Global')]; |
102 | 104 |
|
103 | 105 | $scope = ($item['store_id']) ? 'stores' : (($item['store_website_id']) ? 'websites' : 'default'); |
104 | 106 | $scopeId = (int) $item['store_website_id'] ?? 0; |
105 | 107 | $themeId = (int) $item['theme_theme_id'] ?? 0; |
106 | | - $usingDefaultTheme = $this->isUsingDefaultTheme($scopeId, $themeId, $scope); |
107 | | - $item += ['short_description' => $usingDefaultTheme ? __('Using Default Theme') : '']; |
| 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') : '']; |
108 | 115 | } |
109 | 116 |
|
110 | 117 | return $data; |
111 | 118 | } |
112 | 119 |
|
113 | 120 | /** |
114 | | - * Check if theme used is default theme |
| 121 | + * Get the core config data related to theme |
115 | 122 | * |
116 | | - * @param int $scopeId |
117 | | - * @param int $themeId |
118 | | - * @param string $scope |
119 | | - * @return bool |
| 123 | + * @return array |
120 | 124 | */ |
121 | | - private function isUsingDefaultTheme(int $scopeId, int $themeId, string $scope): bool |
| 125 | + private function getCoreConfigData(): array |
122 | 126 | { |
123 | 127 | $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) |
| 128 | + return $connection->fetchAll( |
| 129 | + $connection->select()->from($connection->getTableName('core_config_data')) |
| 130 | + ->where('path = ?', 'design/theme/theme_id') |
132 | 131 | ); |
133 | | - return !$configId; |
134 | 132 | } |
135 | 133 | } |
0 commit comments