1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Ui\Config;
use Magento\Framework\Config\FileIterator;
use Magento\Framework\Filesystem\DriverPool;
use Magento\Framework\Filesystem\File\ReadFactory;
use Magento\Framework\Module\Dir;
class FileResolverStub implements \Magento\Framework\Config\FileResolverInterface
{
/**
* @var array
*/
private $files = [
'etc/definition.xml' => [
'module_one/ui_component/etc/test_definition.xml',
'module_two/ui_component/etc/test_definition.xml'
],
'etc/definition.map.xml' => [
'ui_component/etc/definition.map.xml'
],
'etc/test_definition.xml' => [
'module_one/ui_component/etc/test_definition.xml',
'module_two/ui_component/etc/test_definition.xml'
],
'test_component.xml' => [
'module_one/ui_component/test_component.xml',
'module_two/ui_component/test_component.xml'
],
'parent_component.xml' => [
'module_one/ui_component/parent_component.xml',
'module_two/ui_component/parent_component.xml'
]
];
/**
* @var Dir\Reader
*/
private $moduleReader;
/**
* FileResolverStub constructor.
*
* @param \Magento\Framework\Module\Dir\Reader $moduleReader
* @param array $files
*/
public function __construct(\Magento\Framework\Module\Dir\Reader $moduleReader, array $files = [])
{
$this->files = array_replace($this->files, $files);
$this->moduleReader = $moduleReader;
}
/**
* {@inheritdoc}
*/
public function get($filename, $scope)
{
if ($filename == 'etc/definition.map.xml') {
$path = $this->moduleReader->getModuleDir(Dir::MODULE_VIEW_DIR, 'Magento_Ui') . '/base';
} else {
$path = realpath(__DIR__ . '/../_files/view');
}
$files = isset($this->files[$filename]) ? $this->files[$filename] : [];
$realPaths = [];
foreach ($files as $filePath) {
$realPaths[] = $path . '/' . $filePath;
}
return new FileIterator(new ReadFactory(new DriverPool), $realPaths);
}
}