Skip to content

Commit f1f2e7a

Browse files
Merge branch '2.3-develop' into MC-37775
2 parents dabf2b4 + 8658b46 commit f1f2e7a

File tree

9 files changed

+437
-17
lines changed

9 files changed

+437
-17
lines changed
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\Csp\Model\Collector\CspWhitelistXml;
10+
11+
use Magento\Framework\Config\FileResolverInterface;
12+
use Magento\Framework\Filesystem;
13+
use Magento\Framework\View\Design\ThemeInterface;
14+
use Magento\Framework\View\DesignInterface;
15+
use Magento\Framework\View\Design\Theme\CustomizationInterface;
16+
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;
20+
21+
/**
22+
* Combines configuration files from both modules and current theme.
23+
*/
24+
class FileResolver implements FileResolverInterface
25+
{
26+
/**
27+
* @var FileResolverInterface
28+
*/
29+
private $moduleFileResolver;
30+
31+
/**
32+
* @var ThemeInterface
33+
*/
34+
private $theme;
35+
36+
/**
37+
* @var CustomizationInterfaceFactory
38+
*/
39+
private $themeInfoFactory;
40+
41+
/**
42+
* @var DirectoryRead
43+
*/
44+
private $rootDir;
45+
46+
/**
47+
* @var CompositeFileIteratorFactory
48+
*/
49+
private $iteratorFactory;
50+
51+
/**
52+
* @param FileResolverInterface $moduleFileResolver
53+
* @param DesignInterface $design
54+
* @param CustomizationInterfaceFactory $customizationFactory
55+
* @param Filesystem $filesystem
56+
* @param CompositeFileIteratorFactory $iteratorFactory
57+
*/
58+
public function __construct(
59+
FileResolverInterface $moduleFileResolver,
60+
DesignInterface $design,
61+
CustomizationInterfaceFactory $customizationFactory,
62+
Filesystem $filesystem,
63+
CompositeFileIteratorFactory $iteratorFactory
64+
) {
65+
$this->moduleFileResolver = $moduleFileResolver;
66+
$this->theme = $design->getDesignTheme();
67+
$this->themeInfoFactory = $customizationFactory;
68+
$this->rootDir = $filesystem->getDirectoryRead(DirectoryList::ROOT);
69+
$this->iteratorFactory = $iteratorFactory;
70+
}
71+
72+
/**
73+
* @inheritDoc
74+
*/
75+
public function get($filename, $scope)
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;
87+
}
88+
$theme = $theme->getParentTheme();
89+
}
90+
$configs = $this->iteratorFactory->create(
91+
['paths' => array_reverse($files), 'existingIterator' => $configs]
92+
);
93+
}
94+
95+
return $configs;
96+
}
97+
}

app/code/Magento/Csp/etc/di.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
<arguments>
4747
<argument name="converter" xsi:type="object">Magento\Csp\Model\Collector\CspWhitelistXml\Converter</argument>
4848
<argument name="schemaLocator" xsi:type="object">Magento\Csp\Model\Collector\CspWhitelistXml\SchemaLocator</argument>
49+
<argument name="fileResolver" xsi:type="object">Magento\Csp\Model\Collector\CspWhitelistXml\FileResolver</argument>
4950
<argument name="fileName" xsi:type="string">csp_whitelist.xml</argument>
5051
</arguments>
5152
</type>

app/code/Magento/Paypal/Test/Mftf/Test/StorefrontPaypalSmartButtonInCheckoutPageTest.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
<severity value="CRITICAL"/>
1818
<testCaseId value="MC-13690"/>
1919
<group value="paypal"/>
20+
<skip>
21+
<issueId value="MC-35792"/>
22+
</skip>
2023
</annotations>
2124
<before>
2225

0 commit comments

Comments
 (0)