|
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
|
|
|
use MageTest\PhpSpec\MagentoExtension\Configuration\MageLocator; |
|
25
|
|
|
use PhpSpec\ServiceContainer; |
|
26
|
|
|
|
|
27
|
|
|
class LocatorAssembler implements Assembler |
|
28
|
|
|
{ |
|
29
|
|
|
private $configuration; |
|
30
|
|
|
|
|
31
|
|
|
public function __construct(MageLocator $configuration) |
|
32
|
|
|
{ |
|
33
|
|
|
$this->configuration = $configuration; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @param ServiceContainer $container |
|
38
|
|
|
*/ |
|
39
|
|
|
public function build(ServiceContainer $container) |
|
40
|
|
|
{ |
|
41
|
|
|
$assembler = $this; |
|
42
|
|
|
$container->addConfigurator(function ($c) use ($assembler) { |
|
43
|
|
|
$config = $assembler->configuration; |
|
44
|
|
|
|
|
45
|
|
|
$srcNS = $config->getNamespace(); |
|
46
|
|
|
$specPrefix = $config->getSpecPrefix(); |
|
47
|
|
|
$srcPath = $config->getSrcPath(); |
|
48
|
|
|
$specPath = $config->getSpecPath(); |
|
49
|
|
|
$codePool = $config->getCodePool(); |
|
50
|
|
|
$filesystem = $c->get('filesystem'); |
|
51
|
|
|
|
|
52
|
|
|
if (!$filesystem->isDirectory($srcPath)) { |
|
53
|
|
|
$filesystem->makeDirectory($srcPath); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
if (!$filesystem->isDirectory($specPath)) { |
|
57
|
|
|
$filesystem->makeDirectory($specPath); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
$factory = new LocatorFactory($srcNS, $specPrefix, $srcPath, $specPath, $filesystem, $codePool); |
|
61
|
|
|
|
|
62
|
|
|
$c->define('locator.locators.magento.model_locator', |
|
63
|
|
|
function () use ($factory) { |
|
64
|
|
|
return $factory->getLocator('model'); |
|
65
|
|
|
}, |
|
66
|
|
|
['locator.locators.magento'] |
|
67
|
|
|
); |
|
68
|
|
|
|
|
69
|
|
|
$c->define('locator.locators.magento.block_locator', |
|
70
|
|
|
function () use ($factory) { |
|
71
|
|
|
return $factory->getLocator('block'); |
|
72
|
|
|
}, |
|
73
|
|
|
['locator.locators.magento'] |
|
74
|
|
|
); |
|
75
|
|
|
|
|
76
|
|
|
$c->define('locator.locators.magento.helper_locator', |
|
77
|
|
|
function () use ($factory) { |
|
78
|
|
|
return $factory->getLocator('helper'); |
|
79
|
|
|
}, |
|
80
|
|
|
['locator.locators.magento'] |
|
81
|
|
|
); |
|
82
|
|
|
|
|
83
|
|
|
$c->define('locator.locators.magento.controller_locator', |
|
84
|
|
|
function () use ($factory) { |
|
85
|
|
|
return $factory->getLocator('controller'); |
|
86
|
|
|
}, |
|
87
|
|
|
['locator.locators.magento'] |
|
88
|
|
|
); |
|
89
|
|
|
|
|
90
|
|
|
$resourceManager = $c->get('locator.resource_manager'); |
|
91
|
|
|
|
|
92
|
|
|
array_map( |
|
93
|
|
|
array($resourceManager, 'registerLocator'), |
|
94
|
|
|
$c->getByTag('locator.locators.magento') |
|
95
|
|
|
); |
|
96
|
|
|
}); |
|
97
|
|
|
} |
|
98
|
|
|
} |
|
99
|
|
|
|