1 | <?php |
||
15 | class Procedure |
||
16 | { |
||
17 | /** |
||
18 | * @var Procedure Parent procedure |
||
19 | */ |
||
20 | protected $parent = null; |
||
21 | |||
22 | /** |
||
23 | * @var array Children |
||
24 | */ |
||
25 | protected $children = array(); |
||
26 | |||
27 | /** |
||
28 | * @var string Procedure name |
||
29 | */ |
||
30 | protected $name; |
||
31 | |||
32 | /** |
||
33 | * @var array Source collection |
||
34 | */ |
||
35 | protected $sources = array(); |
||
36 | |||
37 | /** |
||
38 | * @var array Worker collection |
||
39 | */ |
||
40 | protected $workers = array(); |
||
41 | |||
42 | /** |
||
43 | * @var array Target collection |
||
44 | */ |
||
45 | protected $targets = array(); |
||
46 | |||
47 | /** |
||
48 | * @param string $name Procedure name |
||
49 | * @param array $sources Source collection |
||
50 | * @param array $workers Worker collection |
||
51 | * @param array $targets Target collection |
||
52 | * @param Procedure $parent Parent procedure |
||
53 | */ |
||
54 | 10 | public function __construct($name = null, $sources = array(), $workers = array(), $targets = array(), Procedure $parent = null) |
|
62 | |||
63 | /** |
||
64 | * Creates a procedure from a definition. |
||
65 | * |
||
66 | * Procedure definition must be an array consisting of following elements: |
||
67 | * * name : string |
||
68 | * * sources : array of source adapters |
||
69 | * * workers : array of workers |
||
70 | * * targets : array of target adapters |
||
71 | * |
||
72 | * @param array $definition Procedure definition (how a procedure should be built) |
||
73 | * @param Procedure $parent Parent procedure |
||
74 | * |
||
75 | * @return Procedure |
||
76 | */ |
||
77 | 9 | public static function createFromDefinition(array $definition, Procedure $parent = null) |
|
93 | |||
94 | /** |
||
95 | * Returns parent procedure. |
||
96 | * |
||
97 | * @return Procedure Parent procedure |
||
98 | */ |
||
99 | 4 | public function getParent() |
|
103 | |||
104 | /** |
||
105 | * Returns procedure name. |
||
106 | * |
||
107 | * @return string Procedure name |
||
108 | */ |
||
109 | 3 | public function getName() |
|
113 | |||
114 | /** |
||
115 | * Returns children. |
||
116 | * |
||
117 | * @return array Children procedures |
||
118 | */ |
||
119 | 5 | public function getChildren() |
|
123 | |||
124 | /** |
||
125 | * Tests, if the procedure has children (sub-procedures). |
||
126 | * |
||
127 | * @return bool True, if procedure has children |
||
128 | */ |
||
129 | 3 | public function hasChildren() |
|
133 | |||
134 | /** |
||
135 | * Adds child procedure. |
||
136 | * |
||
137 | * @param Procedure $child Child procedure |
||
138 | */ |
||
139 | 4 | public function addChild(Procedure $child) |
|
143 | |||
144 | /** |
||
145 | * Tests, if a (sub-)procedure exists. |
||
146 | * |
||
147 | * @param string|array $name Procedure name |
||
148 | * @param Procedure $context Current context |
||
149 | * @param int $level Current level |
||
150 | * |
||
151 | * @return bool True, if procedure exists |
||
152 | */ |
||
153 | 3 | public function procedureExists($name, $context = null, $level = 0) |
|
172 | |||
173 | /** |
||
174 | * Returns source collection. |
||
175 | * |
||
176 | * @return array Source collection |
||
177 | */ |
||
178 | 5 | public function getSources() |
|
182 | |||
183 | /** |
||
184 | * Returns worker collection. |
||
185 | * |
||
186 | * @return array Worker collection |
||
187 | */ |
||
188 | 3 | public function getWorkers() |
|
192 | |||
193 | /** |
||
194 | * Returns target collection. |
||
195 | * |
||
196 | * @return array Target collection |
||
197 | */ |
||
198 | 4 | public function getTargets() |
|
202 | |||
203 | /** |
||
204 | * Returns parent settings. |
||
205 | * |
||
206 | * @param string $type Setting type (source, worker or target) |
||
207 | * @param Procedure $context |
||
208 | * |
||
209 | * @return array Setting collection |
||
210 | * |
||
211 | * @internal |
||
212 | */ |
||
213 | 6 | private function getParentSettings($type, $context = null) |
|
234 | |||
235 | /** |
||
236 | * @param Procedure $context |
||
237 | * @param string $method |
||
238 | * |
||
239 | * @return array |
||
240 | * |
||
241 | * @internal |
||
242 | */ |
||
243 | 2 | private function getParentComponentSettings($context, $method) |
|
253 | |||
254 | /** |
||
255 | * @param Procedure|null $context |
||
256 | * |
||
257 | * @return Procedure |
||
258 | * |
||
259 | * @internal |
||
260 | */ |
||
261 | 9 | private function normalizeContext($context = null) |
|
269 | } |
||
270 |