-
Notifications
You must be signed in to change notification settings - Fork 132
/
Copy pathModule.php
67 lines (60 loc) · 1.98 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?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
*/
protected $moduleResolver;
/**
* Module constructor.
* @param ModuleResolver|null $moduleResolver
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
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)
{
$iterator = new File($this->getPaths($filename, $scope));
return $iterator;
}
/**
* Function which takes a string representing filename and a scope represnting directory scope to glob for matched
* patterns against. Returns the file matching the patterns given by the module resolver.
*
* @param string $filename
* @param string $scope
* @return array
*/
protected function getPaths($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));
}
return $paths;
}
}