|
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; |
|
23
|
|
|
|
|
24
|
|
|
use MageTest\PhpSpec\MagentoExtension\Configuration\MageLocator; |
|
25
|
|
|
use MageTest\PhpSpec\MagentoExtension\Extension\CommandAssembler; |
|
26
|
|
|
use MageTest\PhpSpec\MagentoExtension\Extension\GeneratorAssembler; |
|
27
|
|
|
use MageTest\PhpSpec\MagentoExtension\Extension\LocatorAssembler; |
|
28
|
|
|
use MageTest\PhpSpec\MagentoExtension\Listener\ModuleUpdateListener; |
|
29
|
|
|
use MageTest\PhpSpec\MagentoExtension\Util\ClassDetector; |
|
30
|
|
|
use PhpSpec\Extension as PhpspecExtension; |
|
31
|
|
|
use PhpSpec\ServiceContainer; |
|
32
|
|
|
use PhpSpec\Util\Filesystem; |
|
33
|
|
|
use PrettyXml\Formatter; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Extension |
|
37
|
|
|
* |
|
38
|
|
|
* @category MageTest |
|
39
|
|
|
* @package PhpSpec_MagentoExtension |
|
40
|
|
|
* |
|
41
|
|
|
* @author MageTest team (https://github.com/MageTest/MageSpec/contributors) |
|
42
|
|
|
*/ |
|
43
|
|
|
class Extension implements PhpspecExtension |
|
44
|
|
|
{ |
|
45
|
|
|
public function load(ServiceContainer $container, array $params = []) |
|
46
|
|
|
{ |
|
47
|
|
|
$configuration = MageLocator::fromParams($params); |
|
48
|
|
|
$this->setCommands($container); |
|
49
|
|
|
$this->setFilesystem($container); |
|
50
|
|
|
$this->setFormatter($container); |
|
51
|
|
|
$this->setGenerators($container, $configuration); |
|
52
|
|
|
$this->setAccessInspector($container); |
|
53
|
|
|
$this->setLocators($container, $configuration); |
|
54
|
|
|
$this->setUtils($container); |
|
55
|
|
|
$this->setEvents($container, $configuration); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
private function setCommands(ServiceContainer $container) |
|
59
|
|
|
{ |
|
60
|
|
|
$commandAssembler = new CommandAssembler(); |
|
61
|
|
|
$commandAssembler->build($container); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
private function setFilesystem(ServiceContainer $container) |
|
65
|
|
|
{ |
|
66
|
|
|
$container->define('filesystem', function() { |
|
|
|
|
|
|
67
|
|
|
return new Filesystem(); |
|
68
|
|
|
}, ['filesystem']); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
private function setFormatter(ServiceContainer $container) |
|
72
|
|
|
{ |
|
73
|
|
|
$container->define('xml.formatter', function() { |
|
|
|
|
|
|
74
|
|
|
return new Formatter(); |
|
75
|
|
|
}, ['xml.formatter']); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
private function setGenerators(ServiceContainer $container, MageLocator $configuration) |
|
79
|
|
|
{ |
|
80
|
|
|
$generatorAssembler = new GeneratorAssembler($configuration); |
|
81
|
|
|
$generatorAssembler->build($container); |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
private function setAccessInspector(ServiceContainer $container) |
|
85
|
|
|
{ |
|
86
|
|
|
$container->define('access_inspector', function($c) { |
|
|
|
|
|
|
87
|
|
|
return $c->get('access_inspector.visibility'); |
|
88
|
|
|
}, ['access_inspector']); |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
private function setLocators(ServiceContainer $container, MageLocator $configuration) |
|
92
|
|
|
{ |
|
93
|
|
|
$locatorAssembler = new LocatorAssembler($configuration); |
|
94
|
|
|
$locatorAssembler->build($container); |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
private function setUtils(ServiceContainer $container) |
|
98
|
|
|
{ |
|
99
|
|
|
$container->define('util.class_detector', function () { |
|
100
|
|
|
return new ClassDetector(); |
|
101
|
|
|
}, ['util.class_detector']); |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
private function setEvents(ServiceContainer $container, MageLocator $configuration) |
|
105
|
|
|
{ |
|
106
|
|
|
$container->define('event_dispatcher.listeners.bootstrap', function () use ($configuration) { |
|
107
|
|
|
return new Listener\BootstrapListener($configuration); |
|
108
|
|
|
}, ['event_dispatcher.listeners']); |
|
109
|
|
|
|
|
110
|
|
|
$container->define('event_dispatcher.listeners.module_update', function ($c) { |
|
111
|
|
|
return new ModuleUpdateListener( |
|
112
|
|
|
$c->get('xml_generator.generators.module'), |
|
113
|
|
|
$c->get('xml_generator.generators.config'), |
|
114
|
|
|
$c->get('console.io'), |
|
115
|
|
|
$c->get('util.class_detector') |
|
116
|
|
|
); |
|
117
|
|
|
}, ['event_dispatcher.listeners']); |
|
118
|
|
|
} |
|
119
|
|
|
} |
|
120
|
|
|
|