5
5
*/
6
6
namespace Magento \Framework \View \Xsd ;
7
7
8
+ use Magento \Framework \Component \ComponentRegistrar ;
9
+ use Magento \Framework \Component \DirSearch ;
10
+ use Magento \Framework \Config \Dom \UrnResolver ;
8
11
use Magento \Framework \Filesystem ;
9
- use Magento \Framework \Config \FileIteratorFactory ;
10
- use Magento \Framework \App \Filesystem \DirectoryList ;
11
12
12
13
class Reader implements \Magento \Framework \Config \ReaderInterface
13
14
{
@@ -22,69 +23,54 @@ class Reader implements \Magento\Framework\Config\ReaderInterface
22
23
protected $ fileName ;
23
24
24
25
/**
25
- * @var \Magento\Framework\Filesystem\Directory\ReadInterface
26
+ * @var DirSearch
26
27
*/
27
- protected $ directoryRead ;
28
-
29
- /**
30
- * @var \Magento\Framework\Config\FileIteratorFactory
31
- */
32
- protected $ iteratorFactory ;
33
-
34
- /**
35
- * @var string
36
- */
37
- protected $ searchPattern ;
28
+ protected $ componentDirSearch ;
38
29
39
30
/**
40
31
* @var string
41
32
*/
42
33
protected $ searchFilesPattern ;
43
34
35
+ /** @var \Magento\Framework\Config\Dom\UrnResolver */
36
+ protected $ urnResolver ;
37
+
44
38
/**
45
- * @param Filesystem $filesystem
46
- * @param FileIteratorFactory $iteratorFactory
39
+ * @param DirSearch $dirSearch,
47
40
* @param string $fileName
48
41
* @param string $defaultScope
49
- * @param string $searchPattern
50
42
* @param string $searchFilesPattern
51
43
*/
52
44
public function __construct (
53
- Filesystem $ filesystem ,
54
- FileIteratorFactory $ iteratorFactory ,
45
+ DirSearch $ dirSearch ,
46
+ UrnResolver $ urnResolver ,
55
47
$ fileName ,
56
48
$ defaultScope ,
57
- $ searchPattern ,
58
49
$ searchFilesPattern
59
50
) {
60
- $ this ->directoryRead = $ filesystem -> getDirectoryRead (DirectoryList:: MODULES ) ;
61
- $ this ->iteratorFactory = $ iteratorFactory ;
51
+ $ this ->componentDirSearch = $ dirSearch ;
52
+ $ this ->urnResolver = $ urnResolver ;
62
53
$ this ->fileName = $ fileName ;
63
54
$ this ->defaultScope = $ defaultScope ;
64
- $ this ->searchPattern = $ searchPattern ;
65
55
$ this ->searchFilesPattern = $ searchFilesPattern ;
66
56
}
67
57
68
58
/**
69
59
* Get list of xsd files
70
60
*
71
61
* @param string $filename
72
- * @return \Magento\Framework\Config\FileIterator
62
+ * @return array
73
63
*/
74
64
public function getListXsdFiles ($ filename )
75
65
{
76
- $ iterator = $ this ->iteratorFactory ->create (
77
- $ this ->directoryRead ,
78
- $ this ->directoryRead ->search ($ this ->searchPattern . $ filename )
79
- );
80
- return $ iterator ;
66
+ return $ this ->componentDirSearch ->collectFiles (ComponentRegistrar::MODULE , 'etc/ ' . $ filename );
81
67
}
82
68
83
69
/**
84
70
* Read xsd files from list
85
71
*
86
72
* @param null $scope
87
- * @return array|\Magento\Framework\Config\FileIterator
73
+ * @return array
88
74
* @throws \Magento\Framework\Exception\LocalizedException
89
75
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
90
76
*/
@@ -110,7 +96,7 @@ public function read($scope = null)
110
96
public function readXsdFiles ($ fileList , $ baseXsd = null )
111
97
{
112
98
$ baseXsd = new \DOMDocument ();
113
- $ baseXsd ->load (__DIR__ . $ this ->searchFilesPattern . $ this ->fileName );
99
+ $ baseXsd ->load ($ this ->urnResolver -> getRealPath ( $ this -> searchFilesPattern . $ this ->fileName ) );
114
100
$ configMerge = null ;
115
101
foreach ($ fileList as $ key => $ content ) {
116
102
try {
0 commit comments