Skip to content

Commit 758d59e

Browse files
committed
MAGETWO-43452: Ogre sprint 38 contribution to mainline
- using current approach of urn
1 parent 1f08d01 commit 758d59e

File tree

1 file changed

+17
-31
lines changed

1 file changed

+17
-31
lines changed

lib/internal/Magento/Framework/View/Xsd/Reader.php

Lines changed: 17 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
*/
66
namespace Magento\Framework\View\Xsd;
77

8+
use Magento\Framework\Component\ComponentRegistrar;
9+
use Magento\Framework\Component\DirSearch;
10+
use Magento\Framework\Config\Dom\UrnResolver;
811
use Magento\Framework\Filesystem;
9-
use Magento\Framework\Config\FileIteratorFactory;
10-
use Magento\Framework\App\Filesystem\DirectoryList;
1112

1213
class Reader implements \Magento\Framework\Config\ReaderInterface
1314
{
@@ -22,69 +23,54 @@ class Reader implements \Magento\Framework\Config\ReaderInterface
2223
protected $fileName;
2324

2425
/**
25-
* @var \Magento\Framework\Filesystem\Directory\ReadInterface
26+
* @var DirSearch
2627
*/
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;
3829

3930
/**
4031
* @var string
4132
*/
4233
protected $searchFilesPattern;
4334

35+
/** @var \Magento\Framework\Config\Dom\UrnResolver */
36+
protected $urnResolver;
37+
4438
/**
45-
* @param Filesystem $filesystem
46-
* @param FileIteratorFactory $iteratorFactory
39+
* @param DirSearch $dirSearch,
4740
* @param string $fileName
4841
* @param string $defaultScope
49-
* @param string $searchPattern
5042
* @param string $searchFilesPattern
5143
*/
5244
public function __construct(
53-
Filesystem $filesystem,
54-
FileIteratorFactory $iteratorFactory,
45+
DirSearch $dirSearch,
46+
UrnResolver $urnResolver,
5547
$fileName,
5648
$defaultScope,
57-
$searchPattern,
5849
$searchFilesPattern
5950
) {
60-
$this->directoryRead = $filesystem->getDirectoryRead(DirectoryList::MODULES);
61-
$this->iteratorFactory = $iteratorFactory;
51+
$this->componentDirSearch = $dirSearch;
52+
$this->urnResolver = $urnResolver;
6253
$this->fileName = $fileName;
6354
$this->defaultScope = $defaultScope;
64-
$this->searchPattern = $searchPattern;
6555
$this->searchFilesPattern = $searchFilesPattern;
6656
}
6757

6858
/**
6959
* Get list of xsd files
7060
*
7161
* @param string $filename
72-
* @return \Magento\Framework\Config\FileIterator
62+
* @return array
7363
*/
7464
public function getListXsdFiles($filename)
7565
{
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);
8167
}
8268

8369
/**
8470
* Read xsd files from list
8571
*
8672
* @param null $scope
87-
* @return array|\Magento\Framework\Config\FileIterator
73+
* @return array
8874
* @throws \Magento\Framework\Exception\LocalizedException
8975
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
9076
*/
@@ -110,7 +96,7 @@ public function read($scope = null)
11096
public function readXsdFiles($fileList, $baseXsd = null)
11197
{
11298
$baseXsd = new \DOMDocument();
113-
$baseXsd->load(__DIR__ . $this->searchFilesPattern . $this->fileName);
99+
$baseXsd->load($this->urnResolver->getRealPath($this->searchFilesPattern . $this->fileName));
114100
$configMerge = null;
115101
foreach ($fileList as $key => $content) {
116102
try {

0 commit comments

Comments
 (0)