11
11
use Magento \Framework \Filesystem ;
12
12
use Magento \Framework \View \DesignInterface ;
13
13
use Magento \Framework \App \Filesystem \DirectoryList ;
14
- use Symfony \ Component \Config \ Definition \ Exception \ Exception ;
14
+ use Magento \ Framework \ Component \ComponentRegistrar ;
15
15
16
16
class FileResolver implements \Magento \Framework \Config \FileResolverInterface
17
17
{
@@ -43,25 +43,30 @@ class FileResolver implements \Magento\Framework\Config\FileResolverInterface
43
43
protected $ area ;
44
44
45
45
/**
46
- * Root directory
47
- *
48
- * @var ReadInterface
46
+ * @var Filesystem\Directory\ReadInterface
49
47
*/
50
48
protected $ rootDirectory ;
51
49
50
+ /**
51
+ * @var \Magento\Framework\Component\ComponentRegistrar
52
+ */
53
+ protected $ componentRegistrar ;
54
+
52
55
/**
53
56
* @param Reader $moduleReader
54
57
* @param FileIteratorFactory $iteratorFactory
55
58
* @param DesignInterface $designInterface
56
59
* @param DirectoryList $directoryList
57
60
* @param Filesystem $filesystem
61
+ * @param ComponentRegistrar $componentRegistrar
58
62
*/
59
63
public function __construct (
60
64
Reader $ moduleReader ,
61
65
FileIteratorFactory $ iteratorFactory ,
62
66
DesignInterface $ designInterface ,
63
67
DirectoryList $ directoryList ,
64
- Filesystem $ filesystem
68
+ Filesystem $ filesystem ,
69
+ ComponentRegistrar $ componentRegistrar
65
70
) {
66
71
$ this ->directoryList = $ directoryList ;
67
72
$ this ->iteratorFactory = $ iteratorFactory ;
@@ -70,6 +75,7 @@ public function __construct(
70
75
$ this ->themePath = $ designInterface ->getThemePath ($ this ->currentTheme );
71
76
$ this ->area = $ designInterface ->getArea ();
72
77
$ this ->rootDirectory = $ filesystem ->getDirectoryRead (DirectoryList::ROOT );
78
+ $ this ->componentRegistrar = $ componentRegistrar ;
73
79
}
74
80
75
81
/**
@@ -80,7 +86,6 @@ public function get($filename, $scope)
80
86
switch ($ scope ) {
81
87
case 'global ' :
82
88
$ iterator = $ this ->moduleReader ->getConfigurationFiles ($ filename )->toArray ();
83
-
84
89
$ themeConfigFile = $ this ->currentTheme ->getCustomization ()->getCustomViewConfigPath ();
85
90
if ($ themeConfigFile
86
91
&& $ this ->rootDirectory ->isExist ($ this ->rootDirectory ->getRelativePath ($ themeConfigFile ))
@@ -89,20 +94,18 @@ public function get($filename, $scope)
89
94
$ this ->rootDirectory ->getRelativePath ($ themeConfigFile )
90
95
);
91
96
}
92
-
93
97
$ designPath =
94
- $ this ->directoryList ->getPath (DirectoryList::APP )
95
- . '/design/ '
96
- . $ this ->area
97
- . '/ '
98
- . $ this ->themePath
98
+ $ this ->componentRegistrar ->getPath (ComponentRegistrar::THEME , $ this ->area . '/ ' . $ this ->themePath )
99
99
. '/etc/view.xml ' ;
100
100
if (file_exists ($ designPath )) {
101
101
try {
102
102
$ designDom = new \DOMDocument ;
103
103
$ designDom ->load ($ designPath );
104
104
$ iterator [$ designPath ] = $ designDom ->saveXML ();
105
- } catch (Exception $ e ) {
105
+ } catch (\Exception $ e ) {
106
+ throw new \Magento \Framework \Exception \LocalizedException (
107
+ __ ('Could not read config file ' )
108
+ );
106
109
}
107
110
}
108
111
break ;
0 commit comments