forked from magento/magento2-functional-testing-framework
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathModule.php
53 lines (47 loc) · 1.51 KB
/
Module.php
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
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\FunctionalTestingFramework\Config\FileResolver;
use Magento\FunctionalTestingFramework\Util\Iterator\File;
use Magento\FunctionalTestingFramework\Config\FileResolverInterface;
use Magento\FunctionalTestingFramework\Util\ModuleResolver;
/**
* Provides the list of configuration files collected through modules test folders.
*/
class Module implements FileResolverInterface
{
/**
* Resolves module paths based on enabled modules of target Magento instance.
*
* @var ModuleResolver
*/
private $moduleResolver;
/**
* Module constructor.
* @param ModuleResolver|null $moduleResolver
*/
public function __construct(ModuleResolver $moduleResolver = null)
{
$this->moduleResolver = ModuleResolver::getInstance();
}
/**
* Retrieve the list of configuration files with given name that relate to specified scope.
*
* @param string $filename
* @param string $scope
* @return array|\Iterator,\Countable
*/
public function get($filename, $scope)
{
$modulesPath = $this->moduleResolver->getModulesPath();
$paths = [];
foreach ($modulesPath as $modulePath) {
$path = $modulePath . DIRECTORY_SEPARATOR . $scope . DIRECTORY_SEPARATOR . $filename;
$paths = array_merge($paths, glob($path));
}
$iterator = new File($paths);
return $iterator;
}
}