|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* MageSpec |
|
4
|
|
|
* |
|
5
|
|
|
* NOTICE OF LICENSE |
|
6
|
|
|
* |
|
7
|
|
|
* This source file is subject to the MIT License, that is bundled with this |
|
8
|
|
|
* package in the file LICENSE. |
|
9
|
|
|
* It is also available through the world-wide-web at this URL: |
|
10
|
|
|
* |
|
11
|
|
|
* http://opensource.org/licenses/MIT |
|
12
|
|
|
* |
|
13
|
|
|
* If you did not receive a copy of the license and are unable to obtain it |
|
14
|
|
|
* through the world-wide-web, please send an email |
|
15
|
|
|
* to <[email protected]> so we can send you a copy immediately. |
|
16
|
|
|
* |
|
17
|
|
|
* @category MageTest |
|
18
|
|
|
* @package PhpSpec_MagentoExtension |
|
19
|
|
|
* |
|
20
|
|
|
* @copyright Copyright (c) 2012-2013 MageTest team and contributors. |
|
21
|
|
|
*/ |
|
22
|
|
|
namespace MageTest\PhpSpec\MagentoExtension\Extension; |
|
23
|
|
|
|
|
24
|
|
|
|
|
25
|
|
|
use MageTest\PhpSpec\MagentoExtension\Locator\Magento\AbstractResourceLocator; |
|
26
|
|
|
use PhpSpec\Util\Filesystem; |
|
27
|
|
|
|
|
28
|
|
|
class LocatorFactory |
|
29
|
|
|
{ |
|
30
|
|
|
/** |
|
31
|
|
|
* @var string |
|
32
|
|
|
*/ |
|
33
|
|
|
private $sourceNamespace; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @var string |
|
37
|
|
|
*/ |
|
38
|
|
|
private $specPrefix; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @var string |
|
42
|
|
|
*/ |
|
43
|
|
|
private $sourcePath; |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @var string |
|
47
|
|
|
*/ |
|
48
|
|
|
private $specPath; |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* @var string |
|
52
|
|
|
*/ |
|
53
|
|
|
private $codePool; |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* @var Filesystem |
|
57
|
|
|
*/ |
|
58
|
|
|
private $filesystem; |
|
59
|
|
|
|
|
60
|
|
|
public function __construct( |
|
61
|
|
|
$srcNamespace = '', |
|
62
|
|
|
$specNamespacePrefix = '', |
|
63
|
|
|
$srcPath = 'src', |
|
64
|
|
|
$specPath = 'spec', |
|
65
|
|
|
Filesystem $filesystem = null, |
|
66
|
|
|
$codePool = null |
|
67
|
|
|
) { |
|
68
|
|
|
$this->sourceNamespace = $srcNamespace; |
|
69
|
|
|
$this->specPrefix = $specNamespacePrefix; |
|
70
|
|
|
$this->sourcePath = $srcPath; |
|
71
|
|
|
$this->specPath = $specPath; |
|
72
|
|
|
$this->filesystem = $filesystem; |
|
73
|
|
|
$this->codePool = $codePool; |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* @param string $type |
|
78
|
|
|
* @return AbstractResourceLocator |
|
79
|
|
|
*/ |
|
80
|
|
|
public function getLocator($type) |
|
81
|
|
|
{ |
|
82
|
|
|
$className = '\\MageTest\\PhpSpec\\MagentoExtension\\Locator\\Magento\\' . ucfirst($type) . 'Locator'; |
|
83
|
|
|
|
|
84
|
|
|
if (!class_exists($className)) { |
|
85
|
|
|
throw new \RuntimeException("The locator $className does not exist"); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
return new $className( |
|
89
|
|
|
$this->sourceNamespace, |
|
90
|
|
|
$this->specPrefix, |
|
91
|
|
|
$this->sourcePath, |
|
92
|
|
|
$this->specPath, |
|
93
|
|
|
$this->filesystem, |
|
94
|
|
|
$this->codePool |
|
95
|
|
|
); |
|
96
|
|
|
} |
|
97
|
|
|
} |