1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Fwk |
4
|
|
|
* |
5
|
|
|
* Copyright (c) 2011-2012, Julien Ballestracci <[email protected]>. |
6
|
|
|
* All rights reserved. |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
* |
11
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
12
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
13
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
14
|
|
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
15
|
|
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
16
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
17
|
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
18
|
|
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
19
|
|
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
20
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
21
|
|
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
22
|
|
|
* POSSIBILITY OF SUCH DAMAGE. |
23
|
|
|
* |
24
|
|
|
* PHP Version 5.3 |
25
|
|
|
* |
26
|
|
|
* @category DependencyInjection |
27
|
|
|
* @package Fwk\Di |
28
|
|
|
* @author Julien Ballestracci <[email protected]> |
29
|
|
|
* @copyright 2011-2014 Julien Ballestracci <[email protected]> |
30
|
|
|
* @license http://www.opensource.org/licenses/bsd-license.php BSD License |
31
|
|
|
* @link http://www.nitronet.org/fwk |
32
|
|
|
*/ |
33
|
|
|
namespace Fwk\Di\Xml; |
34
|
|
|
|
35
|
|
|
use Fwk\Xml\Map; |
36
|
|
|
use Fwk\Xml\Path; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* ContainerXmlMap |
40
|
|
|
* |
41
|
|
|
* Describes the Map to parse an Xml container. |
42
|
|
|
* |
43
|
|
|
* @category Xml |
44
|
|
|
* @package Fwk\Di |
45
|
|
|
* @author Julien Ballestracci <[email protected]> |
46
|
|
|
* @license http://www.opensource.org/licenses/bsd-license.php BSD License |
47
|
|
|
* @link http://www.nitronet.org/fwk |
48
|
|
|
*/ |
49
|
|
|
class ContainerXmlMap extends Map |
50
|
|
|
{ |
51
|
|
|
/** |
52
|
|
|
* Constructor |
53
|
|
|
* |
54
|
|
|
* Initialize Map paths to return an array of definitions |
55
|
|
|
* |
56
|
|
|
* @void |
57
|
|
|
*/ |
58
|
6 |
|
public function __construct() |
59
|
|
|
{ |
60
|
6 |
|
$this->add( |
61
|
6 |
|
Path::factory( |
62
|
6 |
|
'/dependency-injection/class-definition', |
63
|
6 |
|
'classDefs', |
64
|
6 |
|
array() |
65
|
6 |
|
)->loop(true, '@name') |
66
|
6 |
|
->attribute('shared') |
67
|
6 |
|
->attribute('lazy') |
68
|
6 |
|
->attribute('class', 'className') |
69
|
6 |
|
->addChildren( |
70
|
6 |
|
Path::factory('argument', 'arguments', array()) |
71
|
6 |
|
->loop(true) |
72
|
6 |
|
->value('value') |
73
|
6 |
|
)->addChildren( |
74
|
6 |
|
Path::factory('call', 'methodsCalls', array()) |
75
|
6 |
|
->loop(true) |
76
|
6 |
|
->attribute('method') |
77
|
6 |
|
->addChildren( |
78
|
6 |
|
Path::factory('argument', 'arguments', array()) |
79
|
6 |
|
->loop(true) |
80
|
6 |
|
->value('value') |
81
|
|
|
) |
82
|
6 |
|
)->addChildren( |
83
|
6 |
|
Path::factory('data/param', 'data', array()) |
84
|
6 |
|
->loop(true, '@key') |
85
|
6 |
|
->value('value') |
86
|
|
|
) |
87
|
|
|
); |
88
|
|
|
|
89
|
6 |
|
$this->add( |
90
|
6 |
|
Path::factory( |
91
|
6 |
|
'/dependency-injection/definition', |
92
|
6 |
|
'definitions', |
93
|
6 |
|
array() |
94
|
6 |
|
)->loop(true, '@name') |
95
|
6 |
|
->attribute('shared') |
96
|
6 |
|
->value('value') |
97
|
|
|
); |
98
|
|
|
|
99
|
6 |
|
$this->add( |
100
|
6 |
|
Path::factory('/dependency-injection/ini', 'ini', array()) |
101
|
6 |
|
->loop(true) |
102
|
6 |
|
->attribute('category') |
103
|
6 |
|
->value('value') |
104
|
|
|
); |
105
|
|
|
|
106
|
6 |
|
$this->add( |
107
|
6 |
|
Path::factory( |
108
|
6 |
|
'/dependency-injection/array-definition', |
109
|
6 |
|
'arrayDefs', |
110
|
6 |
|
array() |
111
|
6 |
|
)->loop(true, '@name') |
112
|
6 |
|
->attribute('shared') |
113
|
6 |
|
->addChildren( |
114
|
6 |
|
Path::factory('param', 'params', array()) |
115
|
6 |
|
->loop(true) |
116
|
6 |
|
->attribute('key') |
117
|
6 |
|
->value('value') |
118
|
|
|
) |
119
|
6 |
|
->addChildren( |
120
|
6 |
|
Path::factory('data/param', 'data', array()) |
121
|
6 |
|
->loop(true, '@key') |
122
|
6 |
|
->value('value') |
123
|
|
|
) |
124
|
|
|
); |
125
|
|
|
|
126
|
6 |
|
$this->add( |
127
|
6 |
|
Path::factory( |
128
|
6 |
|
'/dependency-injection/listener', |
129
|
6 |
|
'listeners', |
130
|
6 |
|
array() |
131
|
6 |
|
)->loop(true) |
132
|
6 |
|
->attribute('class') |
133
|
6 |
|
->attribute('service') |
134
|
|
|
); |
135
|
|
|
} |
136
|
|
|
} |