|
8 | 8 |
|
9 | 9 | namespace Magento\Csp\Model\Collector\CspWhitelistXml;
|
10 | 10 |
|
| 11 | +use Magento\Framework\App\Filesystem\DirectoryList; |
| 12 | +use Magento\Framework\Config\CompositeFileIteratorFactory; |
11 | 13 | use Magento\Framework\Config\FileResolverInterface;
|
12 | 14 | use Magento\Framework\Filesystem;
|
13 |
| -use Magento\Framework\View\Design\ThemeInterface; |
14 |
| -use Magento\Framework\View\DesignInterface; |
| 15 | +use Magento\Framework\Filesystem\Directory\ReadInterface as DirectoryRead; |
15 | 16 | use Magento\Framework\View\Design\Theme\CustomizationInterface;
|
16 | 17 | use Magento\Framework\View\Design\Theme\CustomizationInterfaceFactory;
|
17 |
| -use Magento\Framework\App\Filesystem\DirectoryList; |
18 |
| -use Magento\Framework\Filesystem\Directory\ReadInterface as DirectoryRead; |
19 |
| -use Magento\Framework\Config\CompositeFileIteratorFactory; |
| 18 | +use Magento\Framework\View\Design\ThemeInterface; |
| 19 | +use Magento\Framework\View\DesignInterface; |
20 | 20 |
|
21 | 21 | /**
|
22 | 22 | * Combines configuration files from both modules and current theme.
|
@@ -74,22 +74,29 @@ public function __construct(
|
74 | 74 | */
|
75 | 75 | public function get($filename, $scope)
|
76 | 76 | {
|
77 |
| - $configs = $this->moduleFileResolver->get($filename, $scope); |
78 |
| - if ($scope === 'global') { |
79 |
| - $files = []; |
80 |
| - $theme = $this->theme; |
81 |
| - while ($theme) { |
82 |
| - /** @var CustomizationInterface $info */ |
83 |
| - $info = $this->themeInfoFactory->create(['theme' => $theme]); |
84 |
| - $file = $info->getThemeFilesPath() .'/etc/' .$filename; |
85 |
| - if ($this->rootDir->isExist($file)) { |
86 |
| - $files[] = $file; |
| 77 | + $configs = $this->moduleFileResolver->get($filename, $scope); |
| 78 | + |
| 79 | + switch ($scope) { |
| 80 | + case 'frontend': |
| 81 | + case 'adminhtml': |
| 82 | + $files = []; |
| 83 | + $theme = $this->theme; |
| 84 | + while ($theme) { |
| 85 | + /** @var CustomizationInterface $info */ |
| 86 | + $info = $this->themeInfoFactory->create(['theme' => $theme]); |
| 87 | + $file = $info->getThemeFilesPath() . '/etc/' . $filename; |
| 88 | + if ($this->rootDir->isExist($file)) { |
| 89 | + $files[] = $file; |
| 90 | + } |
| 91 | + $theme = $theme->getParentTheme(); |
87 | 92 | }
|
88 |
| - $theme = $theme->getParentTheme(); |
89 |
| - } |
90 |
| - $configs = $this->iteratorFactory->create( |
91 |
| - ['paths' => array_reverse($files), 'existingIterator' => $configs] |
92 |
| - ); |
| 93 | + $configs = $this->iteratorFactory->create( |
| 94 | + ['paths' => array_reverse($files), 'existingIterator' => $configs] |
| 95 | + ); |
| 96 | + break; |
| 97 | + case 'global': |
| 98 | + default: |
| 99 | + break; |
93 | 100 | }
|
94 | 101 |
|
95 | 102 | return $configs;
|
|
0 commit comments