Completed
Pull Request — master (#11)
by Markus
06:07
created
src/config/ConfigValueHolder.class.php 4 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,6 @@
 block discarded – undo
15 15
 
16 16
 namespace Agavi\Config;
17 17
 
18
-use Agavi\Config\Util\Dom\XmlConfigDomElement;
19 18
 use Agavi\Util\Inflector;
20 19
 /**
21 20
  * ConfigValueHolder is the storage class for the XmlConfigHandler
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -105,12 +105,12 @@  discard block
 block discarded – undo
105 105
 	 */
106 106
 	public function __get($name)
107 107
 	{
108
-		if(isset($this->_childs[$name])) {
108
+		if (isset($this->_childs[$name])) {
109 109
 			return $this->_childs[$name];
110 110
 		} else {
111 111
 			$tagName = $name;
112 112
 			$tagNameStart = '';
113
-			if(($lastUScore = strrpos($tagName, '_')) !== false) {
113
+			if (($lastUScore = strrpos($tagName, '_')) !== false) {
114 114
 				$lastUScore++;
115 115
 				$tagNameStart = substr($tagName, 0, $lastUScore);
116 116
 				$tagName = substr($tagName, $lastUScore);
@@ -119,14 +119,14 @@  discard block
 block discarded – undo
119 119
 			// check if the requested node was specified using the plural version
120 120
 			// and create a "virtual" node which reflects the non existent plural node
121 121
 			$singularName = $tagNameStart . Inflector::singularize($tagName);
122
-			if($this->hasChildren($singularName)) {
122
+			if ($this->hasChildren($singularName)) {
123 123
 
124 124
 				$vh = new ConfigValueHolder();
125 125
 				$vh->setName($name);
126 126
 
127 127
 				/** @var ConfigValueHolder $child */
128
-				foreach($this->_childs as $child) {
129
-					if($child->getName() == $singularName) {
128
+				foreach ($this->_childs as $child) {
129
+					if ($child->getName() == $singularName) {
130 130
 						$vh->addChildren($singularName, $child);
131 131
 					}
132 132
 				}
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 	 */
152 152
 	public function addChildren($name, $children)
153 153
 	{
154
-		if(!$this->hasChildren($name)) {
154
+		if (!$this->hasChildren($name)) {
155 155
 			$this->$name = $children;
156 156
 			$this->_childs[$name] = $children;
157 157
 		} else {
@@ -185,16 +185,16 @@  discard block
 block discarded – undo
185 185
 	 */
186 186
 	public function hasChildren($child = null)
187 187
 	{
188
-		if($child === null) {
188
+		if ($child === null) {
189 189
 			return count($this->_childs) > 0;
190 190
 		}
191 191
 
192
-		if(isset($this->_childs[$child])) {
192
+		if (isset($this->_childs[$child])) {
193 193
 			return true;
194 194
 		} else {
195 195
 			$tagName = $child;
196 196
 			$tagNameStart = '';
197
-			if(($lastUScore = strrpos($tagName, '_')) !== false) {
197
+			if (($lastUScore = strrpos($tagName, '_')) !== false) {
198 198
 				$lastUScore++;
199 199
 				$tagNameStart = substr($tagName, 0, $lastUScore);
200 200
 				$tagName = substr($tagName, $lastUScore);
@@ -217,13 +217,13 @@  discard block
 block discarded – undo
217 217
 	 */
218 218
 	public function getChildren($nodename = null)
219 219
 	{
220
-		if($nodename === null) {
220
+		if ($nodename === null) {
221 221
 			return $this->_childs;
222 222
 		} else {
223 223
 			$childs = array();
224 224
 			/** @var ConfigValueHolder $child */
225
-			foreach($this->_childs as $child) {
226
-				if($child->getName() == $nodename) {
225
+			foreach ($this->_childs as $child) {
226
+				if ($child->getName() == $nodename) {
227 227
 					$childs[] = $child;
228 228
 				}
229 229
 			}
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
 	 */
366 366
 	public function offsetGet($offset)
367 367
 	{
368
-		if(!isset($this->_childs[$offset]))
368
+		if (!isset($this->_childs[$offset]))
369 369
 			return null;
370 370
 		return $this->_childs[$offset];
371 371
 	}
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -365,8 +365,9 @@
 block discarded – undo
365 365
 	 */
366 366
 	public function offsetGet($offset)
367 367
 	{
368
-		if(!isset($this->_childs[$offset]))
369
-			return null;
368
+		if(!isset($this->_childs[$offset])) {
369
+					return null;
370
+		}
370 371
 		return $this->_childs[$offset];
371 372
 	}
372 373
 
Please login to merge, or discard this patch.
Indentation   +388 added lines, -388 removed lines patch added patch discarded remove patch
@@ -35,394 +35,394 @@
 block discarded – undo
35 35
  */
36 36
 class ConfigValueHolder implements \ArrayAccess, \IteratorAggregate
37 37
 {
38
-	/**
39
-	 * @var        string The name of this value.
40
-	 */
41
-	protected $_name = '';
42
-	/**
43
-	 * @var        array The attributes of this value.
44
-	 */
45
-	protected $_attributes = array();
46
-	/**
47
-	 * @var        array The child nodes of this value.
48
-	 */
49
-	protected $_childs = array();
50
-	/**
51
-	 * @var        string The value.
52
-	 */
53
-	protected $_value = null;
54
-
55
-	/**
56
-	 * Sets the name of this value.
57
-	 *
58
-	 * @param      string $name The name.
59
-	 *
60
-	 * @author     Dominik del Bondio <[email protected]>
61
-	 * @since      0.11.0
62
-	 */
63
-	public function setName($name)
64
-	{
65
-		$this->_name = $name;
66
-	}
67
-
68
-	/**
69
-	 * Returns the name of this value.
70
-	 *
71
-	 * @return     string The name.
72
-	 *
73
-	 * @author     Dominik del Bondio <[email protected]>
74
-	 * @since      0.11.0
75
-	 */
76
-	public function getName()
77
-	{
78
-		return $this->_name;
79
-	}
80
-
81
-	/**
82
-	 * isset() overload.
83
-	 *
84
-	 * @param      string $name Name of the child.
85
-	 *
86
-	 * @return     bool Whether or not that child exists.
87
-	 *
88
-	 * @author     Dominik del Bondio <[email protected]>
89
-	 * @since      0.11.0
90
-	 */
91
-	public function __isset($name)
92
-	{
93
-		return $this->hasChildren($name);
94
-	}
95
-
96
-	/**
97
-	 * Magic getter overload.
98
-	 *
99
-	 * @param      string $name Name of the child .
100
-	 *
101
-	 * @return     ConfigValueHolder The child, if it exists.
102
-	 *
103
-	 * @author     Dominik del Bondio <[email protected]>
104
-	 * @since      0.11.0
105
-	 */
106
-	public function __get($name)
107
-	{
108
-		if(isset($this->_childs[$name])) {
109
-			return $this->_childs[$name];
110
-		} else {
111
-			$tagName = $name;
112
-			$tagNameStart = '';
113
-			if(($lastUScore = strrpos($tagName, '_')) !== false) {
114
-				$lastUScore++;
115
-				$tagNameStart = substr($tagName, 0, $lastUScore);
116
-				$tagName = substr($tagName, $lastUScore);
117
-			}
118
-
119
-			// check if the requested node was specified using the plural version
120
-			// and create a "virtual" node which reflects the non existent plural node
121
-			$singularName = $tagNameStart . Inflector::singularize($tagName);
122
-			if($this->hasChildren($singularName)) {
123
-
124
-				$vh = new ConfigValueHolder();
125
-				$vh->setName($name);
126
-
127
-				/** @var ConfigValueHolder $child */
128
-				foreach($this->_childs as $child) {
129
-					if($child->getName() == $singularName) {
130
-						$vh->addChildren($singularName, $child);
131
-					}
132
-				}
133
-
134
-				return $vh;
135
-			} else {
136
-				//throw new AgaviException('Node with the name ' . $name . ' does not exist ('.$this->getName().', '.implode(', ', array_keys($this->_childs)).')');
137
-				return null;
138
-			}
139
-		}
140
-	}
141
-
142
-	/**
143
-	 * Adds a named children to this value. If a children with the same name
144
-	 * already exists the given value will be appended to the children.
145
-	 *
146
-	 * @param      string            $name     The name of the child.
147
-	 * @param      ConfigValueHolder $children The child value.
148
-	 *
149
-	 * @author     Dominik del Bondio <[email protected]>
150
-	 * @since      0.11.0
151
-	 */
152
-	public function addChildren($name, $children)
153
-	{
154
-		if(!$this->hasChildren($name)) {
155
-			$this->$name = $children;
156
-			$this->_childs[$name] = $children;
157
-		} else {
158
-			$this->appendChildren($children);
159
-		}
160
-	}
161
-
162
-	/**
163
-	 * Adds a unnamed children to this value.
164
-	 *
165
-	 * @param      ConfigValueHolder $children The child value.
166
-	 *
167
-	 * @author     Dominik del Bondio <[email protected]>
168
-	 * @since      0.11.0
169
-	 */
170
-	public function appendChildren($children)
171
-	{
172
-		$this->_childs[] = $children;
173
-	}
174
-
175
-	/**
176
-	 * Checks whether the value has children at all (no params) or whether a
177
-	 * child with the given name exists.
178
-	 *
179
-	 * @param      string $child The name of the child.
180
-	 *
181
-	 * @return     bool True if children exist, false if not.
182
-	 *
183
-	 * @author     Dominik del Bondio <[email protected]>
184
-	 * @since      0.11.0
185
-	 */
186
-	public function hasChildren($child = null)
187
-	{
188
-		if($child === null) {
189
-			return count($this->_childs) > 0;
190
-		}
191
-
192
-		if(isset($this->_childs[$child])) {
193
-			return true;
194
-		} else {
195
-			$tagName = $child;
196
-			$tagNameStart = '';
197
-			if(($lastUScore = strrpos($tagName, '_')) !== false) {
198
-				$lastUScore++;
199
-				$tagNameStart = substr($tagName, 0, $lastUScore);
200
-				$tagName = substr($tagName, $lastUScore);
201
-			}
202
-
203
-			$singularName = $tagNameStart . Inflector::singularize($tagName);
204
-			return isset($this->_childs[$singularName]);
205
-		}
206
-	}
207
-
208
-	/**
209
-	 * Returns the children of this value.
210
-	 *
211
-	 * @param      string $nodename Return only the childs matching this node (tag) name.
212
-	 *
213
-	 * @return     ConfigValueHolder[] An array with the childs of this value.
214
-	 *
215
-	 * @author     Dominik del Bondio <[email protected]>
216
-	 * @since      0.11.0
217
-	 */
218
-	public function getChildren($nodename = null)
219
-	{
220
-		if($nodename === null) {
221
-			return $this->_childs;
222
-		} else {
223
-			$childs = array();
224
-			/** @var ConfigValueHolder $child */
225
-			foreach($this->_childs as $child) {
226
-				if($child->getName() == $nodename) {
227
-					$childs[] = $child;
228
-				}
229
-			}
230
-
231
-			return $childs;
232
-		}
233
-	}
234
-
235
-	/**
236
-	 * Set an attribute.
237
-	 *
238
-	 * If an attribute with the name already exists the value will be
239
-	 * overridden.
240
-	 *
241
-	 * @param      string $name  An attribute name.
242
-	 * @param      mixed  $value An attribute value.
243
-	 *
244
-	 * @author     Dominik del Bondio <[email protected]>
245
-	 * @since      0.11.0
246
-	 */
247
-	public function setAttribute($name, $value)
248
-	{
249
-		$this->_attributes[$name] = $value;
250
-	}
251
-
252
-	/**
253
-	 * Indicates whether or not an attribute exists.
254
-	 *
255
-	 * @param      string $name An attribute name.
256
-	 *
257
-	 * @return     bool true, if the attribute exists, otherwise false.
258
-	 *
259
-	 * @author     Dominik del Bondio <[email protected]>
260
-	 * @since      0.11.0
261
-	 */
262
-	public function hasAttribute($name)
263
-	{
264
-		return isset($this->_attributes[$name]);
265
-	}
266
-
267
-	/**
268
-	 * Retrieve an attribute.
269
-	 *
270
-	 * @param      string $name    An attribute name.
271
-	 * @param      mixed  $default A default attribute value.
272
-	 *
273
-	 * @return     mixed An attribute value, if the attribute exists, otherwise
274
-	 *                   null or the given default.
275
-	 *
276
-	 * @author     Dominik del Bondio <[email protected]>
277
-	 * @since      0.11.0
278
-	 */
279
-	public function getAttribute($name, $default = null)
280
-	{
281
-		return isset($this->_attributes[$name]) ? $this->_attributes[$name] : $default;
282
-	}
283
-
284
-	/**
285
-	 * Retrieve all attributes.
286
-	 *
287
-	 * @return     array An associative array of attributes.
288
-	 *
289
-	 * @author     Dominik del Bondio <[email protected]>
290
-	 * @since      0.11.0
291
-	 */
292
-	public function getAttributes()
293
-	{
294
-		return $this->_attributes;
295
-	}
296
-
297
-	/**
298
-	 * Set the value of this value node.
299
-	 *
300
-	 * @param      string $value A value.
301
-	 *
302
-	 * @author     Dominik del Bondio <[email protected]>
303
-	 * @since      0.11.0
304
-	 */
305
-	public function setValue($value)
306
-	{
307
-		$this->_value = $value;
308
-	}
309
-
310
-	/**
311
-	 * Retrieves the value of this value node.
312
-	 *
313
-	 * @return     string The value of this node.
314
-	 *
315
-	 * @author     Dominik del Bondio <[email protected]>
316
-	 * @since      0.11.0
317
-	 */
318
-	public function getValue()
319
-	{
320
-		return $this->_value;
321
-	}
322
-
323
-	/**
324
-	 * Retrieves the info of this value node.
325
-	 *
326
-	 * @return     array An array containing the info for this node.
327
-	 *
328
-	 * @author     Dominik del Bondio <[email protected]>
329
-	 * @since      0.11.0
330
-	 */
331
-	public function getNode()
332
-	{
333
-		return array(
334
-			'name' => $this->_name,
335
-			'attributes' => $this->_attributes,
336
-			'children' => $this->_childs,
337
-			'value' => $this->_value,
338
-		);
339
-	}
340
-
341
-	/**
342
-	 * Determines if a named child exists. From ArrayAccess.
343
-	 *
344
-	 * @param      string $offset Offset to check
345
-	 *
346
-	 * @return     bool Whether the offset exists.
347
-	 *
348
-	 * @author     Dominik del Bondio <[email protected]>
349
-	 * @since      0.11.0
350
-	 */
351
-	public function offsetExists($offset)
352
-	{
353
-		return isset($this->_childs[$offset]);
354
-	}
355
-
356
-	/**
357
-	 * Retrieves a named child. From ArrayAccess.
358
-	 *
359
-	 * @param      string $offset Offset to retrieve
360
-	 *
361
-	 * @return     ConfigValueHolder The child value.
362
-	 *
363
-	 * @author     Dominik del Bondio <[email protected]>
364
-	 * @since      0.11.0
365
-	 */
366
-	public function offsetGet($offset)
367
-	{
368
-		if(!isset($this->_childs[$offset]))
369
-			return null;
370
-		return $this->_childs[$offset];
371
-	}
372
-
373
-	/**
374
-	 * Inserts a named child. From ArrayAccess.
375
-	 *
376
-	 * @param      string            $offset Offset to modify
377
-	 * @param      ConfigValueHolder $value  The child value.
378
-	 *
379
-	 * @author     Dominik del Bondio <[email protected]>
380
-	 * @since      0.11.0
381
-	 */
382
-	public function offsetSet($offset, $value)
383
-	{
384
-		$this->_childs[$offset] = $value;
385
-	}
386
-
387
-	/**
388
-	 * Deletes a named child. From ArrayAccess.
389
-	 *
390
-	 * @return     string $offset Offset to delete.
391
-	 *
392
-	 * @author     Dominik del Bondio <[email protected]>
393
-	 * @since      0.11.0
394
-	 */
395
-	public function offsetUnset($offset)
396
-	{
397
-		unset($this->_childs[$offset]);
398
-	}
399
-
400
-	/**
401
-	 * Returns an Iterator for the child nodes. From IteratorAggregate.
402
-	 *
403
-	 * @return     \Iterator The iterator.
404
-	 *
405
-	 * @author     Dominik del Bondio <[email protected]>
406
-	 * @since      0.11.0
407
-	 */
408
-	public function getIterator()
409
-	{
410
-		return new \ArrayIterator($this->getChildren());
411
-	}
412
-
413
-	/**
414
-	 * Retrieves the string representation of this value node. This is 
415
-	 * currently only the value of the node.
416
-	 *
417
-	 * @return     string The string representation.
418
-	 *
419
-	 * @author     Dominik del Bondio <[email protected]>
420
-	 * @since      0.11.0
421
-	 */
422
-	public function __toString()
423
-	{
424
-		return $this->_value;
425
-	}
38
+    /**
39
+     * @var        string The name of this value.
40
+     */
41
+    protected $_name = '';
42
+    /**
43
+     * @var        array The attributes of this value.
44
+     */
45
+    protected $_attributes = array();
46
+    /**
47
+     * @var        array The child nodes of this value.
48
+     */
49
+    protected $_childs = array();
50
+    /**
51
+     * @var        string The value.
52
+     */
53
+    protected $_value = null;
54
+
55
+    /**
56
+     * Sets the name of this value.
57
+     *
58
+     * @param      string $name The name.
59
+     *
60
+     * @author     Dominik del Bondio <[email protected]>
61
+     * @since      0.11.0
62
+     */
63
+    public function setName($name)
64
+    {
65
+        $this->_name = $name;
66
+    }
67
+
68
+    /**
69
+     * Returns the name of this value.
70
+     *
71
+     * @return     string The name.
72
+     *
73
+     * @author     Dominik del Bondio <[email protected]>
74
+     * @since      0.11.0
75
+     */
76
+    public function getName()
77
+    {
78
+        return $this->_name;
79
+    }
80
+
81
+    /**
82
+     * isset() overload.
83
+     *
84
+     * @param      string $name Name of the child.
85
+     *
86
+     * @return     bool Whether or not that child exists.
87
+     *
88
+     * @author     Dominik del Bondio <[email protected]>
89
+     * @since      0.11.0
90
+     */
91
+    public function __isset($name)
92
+    {
93
+        return $this->hasChildren($name);
94
+    }
95
+
96
+    /**
97
+     * Magic getter overload.
98
+     *
99
+     * @param      string $name Name of the child .
100
+     *
101
+     * @return     ConfigValueHolder The child, if it exists.
102
+     *
103
+     * @author     Dominik del Bondio <[email protected]>
104
+     * @since      0.11.0
105
+     */
106
+    public function __get($name)
107
+    {
108
+        if(isset($this->_childs[$name])) {
109
+            return $this->_childs[$name];
110
+        } else {
111
+            $tagName = $name;
112
+            $tagNameStart = '';
113
+            if(($lastUScore = strrpos($tagName, '_')) !== false) {
114
+                $lastUScore++;
115
+                $tagNameStart = substr($tagName, 0, $lastUScore);
116
+                $tagName = substr($tagName, $lastUScore);
117
+            }
118
+
119
+            // check if the requested node was specified using the plural version
120
+            // and create a "virtual" node which reflects the non existent plural node
121
+            $singularName = $tagNameStart . Inflector::singularize($tagName);
122
+            if($this->hasChildren($singularName)) {
123
+
124
+                $vh = new ConfigValueHolder();
125
+                $vh->setName($name);
126
+
127
+                /** @var ConfigValueHolder $child */
128
+                foreach($this->_childs as $child) {
129
+                    if($child->getName() == $singularName) {
130
+                        $vh->addChildren($singularName, $child);
131
+                    }
132
+                }
133
+
134
+                return $vh;
135
+            } else {
136
+                //throw new AgaviException('Node with the name ' . $name . ' does not exist ('.$this->getName().', '.implode(', ', array_keys($this->_childs)).')');
137
+                return null;
138
+            }
139
+        }
140
+    }
141
+
142
+    /**
143
+     * Adds a named children to this value. If a children with the same name
144
+     * already exists the given value will be appended to the children.
145
+     *
146
+     * @param      string            $name     The name of the child.
147
+     * @param      ConfigValueHolder $children The child value.
148
+     *
149
+     * @author     Dominik del Bondio <[email protected]>
150
+     * @since      0.11.0
151
+     */
152
+    public function addChildren($name, $children)
153
+    {
154
+        if(!$this->hasChildren($name)) {
155
+            $this->$name = $children;
156
+            $this->_childs[$name] = $children;
157
+        } else {
158
+            $this->appendChildren($children);
159
+        }
160
+    }
161
+
162
+    /**
163
+     * Adds a unnamed children to this value.
164
+     *
165
+     * @param      ConfigValueHolder $children The child value.
166
+     *
167
+     * @author     Dominik del Bondio <[email protected]>
168
+     * @since      0.11.0
169
+     */
170
+    public function appendChildren($children)
171
+    {
172
+        $this->_childs[] = $children;
173
+    }
174
+
175
+    /**
176
+     * Checks whether the value has children at all (no params) or whether a
177
+     * child with the given name exists.
178
+     *
179
+     * @param      string $child The name of the child.
180
+     *
181
+     * @return     bool True if children exist, false if not.
182
+     *
183
+     * @author     Dominik del Bondio <[email protected]>
184
+     * @since      0.11.0
185
+     */
186
+    public function hasChildren($child = null)
187
+    {
188
+        if($child === null) {
189
+            return count($this->_childs) > 0;
190
+        }
191
+
192
+        if(isset($this->_childs[$child])) {
193
+            return true;
194
+        } else {
195
+            $tagName = $child;
196
+            $tagNameStart = '';
197
+            if(($lastUScore = strrpos($tagName, '_')) !== false) {
198
+                $lastUScore++;
199
+                $tagNameStart = substr($tagName, 0, $lastUScore);
200
+                $tagName = substr($tagName, $lastUScore);
201
+            }
202
+
203
+            $singularName = $tagNameStart . Inflector::singularize($tagName);
204
+            return isset($this->_childs[$singularName]);
205
+        }
206
+    }
207
+
208
+    /**
209
+     * Returns the children of this value.
210
+     *
211
+     * @param      string $nodename Return only the childs matching this node (tag) name.
212
+     *
213
+     * @return     ConfigValueHolder[] An array with the childs of this value.
214
+     *
215
+     * @author     Dominik del Bondio <[email protected]>
216
+     * @since      0.11.0
217
+     */
218
+    public function getChildren($nodename = null)
219
+    {
220
+        if($nodename === null) {
221
+            return $this->_childs;
222
+        } else {
223
+            $childs = array();
224
+            /** @var ConfigValueHolder $child */
225
+            foreach($this->_childs as $child) {
226
+                if($child->getName() == $nodename) {
227
+                    $childs[] = $child;
228
+                }
229
+            }
230
+
231
+            return $childs;
232
+        }
233
+    }
234
+
235
+    /**
236
+     * Set an attribute.
237
+     *
238
+     * If an attribute with the name already exists the value will be
239
+     * overridden.
240
+     *
241
+     * @param      string $name  An attribute name.
242
+     * @param      mixed  $value An attribute value.
243
+     *
244
+     * @author     Dominik del Bondio <[email protected]>
245
+     * @since      0.11.0
246
+     */
247
+    public function setAttribute($name, $value)
248
+    {
249
+        $this->_attributes[$name] = $value;
250
+    }
251
+
252
+    /**
253
+     * Indicates whether or not an attribute exists.
254
+     *
255
+     * @param      string $name An attribute name.
256
+     *
257
+     * @return     bool true, if the attribute exists, otherwise false.
258
+     *
259
+     * @author     Dominik del Bondio <[email protected]>
260
+     * @since      0.11.0
261
+     */
262
+    public function hasAttribute($name)
263
+    {
264
+        return isset($this->_attributes[$name]);
265
+    }
266
+
267
+    /**
268
+     * Retrieve an attribute.
269
+     *
270
+     * @param      string $name    An attribute name.
271
+     * @param      mixed  $default A default attribute value.
272
+     *
273
+     * @return     mixed An attribute value, if the attribute exists, otherwise
274
+     *                   null or the given default.
275
+     *
276
+     * @author     Dominik del Bondio <[email protected]>
277
+     * @since      0.11.0
278
+     */
279
+    public function getAttribute($name, $default = null)
280
+    {
281
+        return isset($this->_attributes[$name]) ? $this->_attributes[$name] : $default;
282
+    }
283
+
284
+    /**
285
+     * Retrieve all attributes.
286
+     *
287
+     * @return     array An associative array of attributes.
288
+     *
289
+     * @author     Dominik del Bondio <[email protected]>
290
+     * @since      0.11.0
291
+     */
292
+    public function getAttributes()
293
+    {
294
+        return $this->_attributes;
295
+    }
296
+
297
+    /**
298
+     * Set the value of this value node.
299
+     *
300
+     * @param      string $value A value.
301
+     *
302
+     * @author     Dominik del Bondio <[email protected]>
303
+     * @since      0.11.0
304
+     */
305
+    public function setValue($value)
306
+    {
307
+        $this->_value = $value;
308
+    }
309
+
310
+    /**
311
+     * Retrieves the value of this value node.
312
+     *
313
+     * @return     string The value of this node.
314
+     *
315
+     * @author     Dominik del Bondio <[email protected]>
316
+     * @since      0.11.0
317
+     */
318
+    public function getValue()
319
+    {
320
+        return $this->_value;
321
+    }
322
+
323
+    /**
324
+     * Retrieves the info of this value node.
325
+     *
326
+     * @return     array An array containing the info for this node.
327
+     *
328
+     * @author     Dominik del Bondio <[email protected]>
329
+     * @since      0.11.0
330
+     */
331
+    public function getNode()
332
+    {
333
+        return array(
334
+            'name' => $this->_name,
335
+            'attributes' => $this->_attributes,
336
+            'children' => $this->_childs,
337
+            'value' => $this->_value,
338
+        );
339
+    }
340
+
341
+    /**
342
+     * Determines if a named child exists. From ArrayAccess.
343
+     *
344
+     * @param      string $offset Offset to check
345
+     *
346
+     * @return     bool Whether the offset exists.
347
+     *
348
+     * @author     Dominik del Bondio <[email protected]>
349
+     * @since      0.11.0
350
+     */
351
+    public function offsetExists($offset)
352
+    {
353
+        return isset($this->_childs[$offset]);
354
+    }
355
+
356
+    /**
357
+     * Retrieves a named child. From ArrayAccess.
358
+     *
359
+     * @param      string $offset Offset to retrieve
360
+     *
361
+     * @return     ConfigValueHolder The child value.
362
+     *
363
+     * @author     Dominik del Bondio <[email protected]>
364
+     * @since      0.11.0
365
+     */
366
+    public function offsetGet($offset)
367
+    {
368
+        if(!isset($this->_childs[$offset]))
369
+            return null;
370
+        return $this->_childs[$offset];
371
+    }
372
+
373
+    /**
374
+     * Inserts a named child. From ArrayAccess.
375
+     *
376
+     * @param      string            $offset Offset to modify
377
+     * @param      ConfigValueHolder $value  The child value.
378
+     *
379
+     * @author     Dominik del Bondio <[email protected]>
380
+     * @since      0.11.0
381
+     */
382
+    public function offsetSet($offset, $value)
383
+    {
384
+        $this->_childs[$offset] = $value;
385
+    }
386
+
387
+    /**
388
+     * Deletes a named child. From ArrayAccess.
389
+     *
390
+     * @return     string $offset Offset to delete.
391
+     *
392
+     * @author     Dominik del Bondio <[email protected]>
393
+     * @since      0.11.0
394
+     */
395
+    public function offsetUnset($offset)
396
+    {
397
+        unset($this->_childs[$offset]);
398
+    }
399
+
400
+    /**
401
+     * Returns an Iterator for the child nodes. From IteratorAggregate.
402
+     *
403
+     * @return     \Iterator The iterator.
404
+     *
405
+     * @author     Dominik del Bondio <[email protected]>
406
+     * @since      0.11.0
407
+     */
408
+    public function getIterator()
409
+    {
410
+        return new \ArrayIterator($this->getChildren());
411
+    }
412
+
413
+    /**
414
+     * Retrieves the string representation of this value node. This is 
415
+     * currently only the value of the node.
416
+     *
417
+     * @return     string The string representation.
418
+     *
419
+     * @author     Dominik del Bondio <[email protected]>
420
+     * @since      0.11.0
421
+     */
422
+    public function __toString()
423
+    {
424
+        return $this->_value;
425
+    }
426 426
 }
427 427
 
428 428
 ?>
429 429
\ No newline at end of file
Please login to merge, or discard this patch.
src/config/LdmlConfigHandler.class.php 3 patches
Doc Comments   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -846,6 +846,7 @@  discard block
 block discarded – undo
846 846
 	 * @param      ConfigValueHolder The item.
847 847
 	 * @param      string The name of item.
848 848
 	 * @param      array The array to store the parsed data to.
849
+	 * @param string $name
849 850
 	 *
850 851
 	 * @return     array The array with the data.
851 852
 	 *
@@ -1004,7 +1005,7 @@  discard block
 block discarded – undo
1004 1005
 	 * Unescapes a single unicode escape sequence. This is designed to be a 
1005 1006
 	 * preg_replace_callback callback function.
1006 1007
 	 * 
1007
-	 * @param      array $matches The match.
1008
+	 * @param      string[] $matches The match.
1008 1009
 	 *
1009 1010
 	 * @return     string The unescaped sequence.
1010 1011
 	 *
Please login to merge, or discard this patch.
Spacing   +169 added lines, -169 removed lines patch added patch discarded remove patch
@@ -64,9 +64,9 @@  discard block
 block discarded – undo
64 64
 			'layout' => array('orientation' => array('lines' => 'top-to-bottom', 'characters' => 'left-to-right')),
65 65
 		);
66 66
 
67
-		foreach(array_reverse($lookupPaths) as $basename) {
67
+		foreach (array_reverse($lookupPaths) as $basename) {
68 68
 			$filePath = $pathParts['dirname'] . '/' . $basename . '.' . $pathParts['extension'];
69
-			if(is_readable($filePath)) {
69
+			if (is_readable($filePath)) {
70 70
 				$ldmlTree = ConfigCache::parseConfig($filePath, false, $this->getValidationFile(), $this->parser);
71 71
 				$this->prepareParentInformation($ldmlTree);
72 72
 				$this->parseLdmlTree($ldmlTree->ldml, $data);
@@ -84,14 +84,14 @@  discard block
 block discarded – undo
84 84
 		);
85 85
 
86 86
 		// fix the day indices for all day fields
87
-		foreach($data['calendars'] as $calKey => &$calValue) {
87
+		foreach ($data['calendars'] as $calKey => &$calValue) {
88 88
 			// skip the 'default' => '' key => value pair
89
-			if(is_array($calValue)) {
90
-				if(isset($calValue['days']['format'])) {
91
-					foreach($calValue['days']['format'] as $formatKey => &$formatValue) {
92
-						if(is_array($formatValue)) {
89
+			if (is_array($calValue)) {
90
+				if (isset($calValue['days']['format'])) {
91
+					foreach ($calValue['days']['format'] as $formatKey => &$formatValue) {
92
+						if (is_array($formatValue)) {
93 93
 							$newData = array();
94
-							foreach($formatValue as $day => $value) {
94
+							foreach ($formatValue as $day => $value) {
95 95
 								$newData[$dayMap[$day]] = $value;
96 96
 							}
97 97
 							$formatValue = $newData;
@@ -99,11 +99,11 @@  discard block
 block discarded – undo
99 99
 					}
100 100
 				}
101 101
 
102
-				if(isset($calValue['days']['stand-alone'])) {
103
-					foreach($calValue['days']['stand-alone'] as $formatKey => &$formatValue) {
104
-						if(is_array($formatValue)) {
102
+				if (isset($calValue['days']['stand-alone'])) {
103
+					foreach ($calValue['days']['stand-alone'] as $formatKey => &$formatValue) {
104
+						if (is_array($formatValue)) {
105 105
 							$newData = array();
106
-							foreach($formatValue as $day => $value) {
106
+							foreach ($formatValue as $day => $value) {
107 107
 								$newData[$dayMap[$day]] = $value;
108 108
 							}
109 109
 							$formatValue = $newData;
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 		$ldmlTree->setAttribute('__agavi_parent_id', null);
136 136
 		$this->nodeRefs[$i] = $ldmlTree;
137 137
 		++$i;
138
-		if($ldmlTree->hasChildren()) {
138
+		if ($ldmlTree->hasChildren()) {
139 139
 			$this->generateParentInformation($ldmlTree->getChildren(), $i, 0);
140 140
 		}
141 141
 	}
@@ -153,12 +153,12 @@  discard block
 block discarded – undo
153 153
 	protected function generateParentInformation($childList, &$nextId, $parentId)
154 154
 	{
155 155
 		/** @var ConfigValueHolder $child */
156
-		foreach($childList as $child) {
156
+		foreach ($childList as $child) {
157 157
 			$child->setAttribute('__agavi_node_id', $nextId);
158 158
 			$child->setAttribute('__agavi_parent_id', $parentId);
159 159
 			$this->nodeRefs[$nextId] = $child;
160 160
 			++$nextId;
161
-			if($child->hasChildren()) {
161
+			if ($child->hasChildren()) {
162 162
 				$this->generateParentInformation($child->getChildren(), $nextId, $child->getAttribute('__agavi_node_id'));
163 163
 			}
164 164
 		}
@@ -350,43 +350,43 @@  discard block
 block discarded – undo
350 350
 	public function parseLdmlTree($ldmlTree, &$data)
351 351
 	{
352 352
 
353
-		if(isset($ldmlTree->identity)) {
353
+		if (isset($ldmlTree->identity)) {
354 354
 			$data['locale']['language'] = $ldmlTree->identity->language->getAttribute('type');
355
-			if(isset($ldmlTree->identity->territory)) {
355
+			if (isset($ldmlTree->identity->territory)) {
356 356
 				$data['locale']['territory'] = $ldmlTree->identity->territory->getAttribute('type');
357 357
 			}
358
-			if(isset($ldmlTree->identity->script)) {
358
+			if (isset($ldmlTree->identity->script)) {
359 359
 				$data['locale']['script'] = $ldmlTree->identity->script->getAttribute('type');
360 360
 			}
361
-			if(isset($ldmlTree->identity->variant)) {
361
+			if (isset($ldmlTree->identity->variant)) {
362 362
 				$data['locale']['variant'] = $ldmlTree->identity->variant->getAttribute('type');
363 363
 			}
364 364
 		}
365 365
 
366
-		if(isset($ldmlTree->localeDisplayNames)) {
366
+		if (isset($ldmlTree->localeDisplayNames)) {
367 367
 			$ldn = $ldmlTree->localeDisplayNames;
368 368
 
369
-			if(isset($ldn->languages)) {
369
+			if (isset($ldn->languages)) {
370 370
 				$data['displayNames']['languages'] = isset($data['displayNames']['languages']) ? $data['displayNames']['languages'] : array();
371 371
 				$this->getTypeList($ldn->languages, $data['displayNames']['languages']);
372 372
 			}
373 373
 
374
-			if(isset($ldn->scripts)) {
374
+			if (isset($ldn->scripts)) {
375 375
 				$data['displayNames']['scripts'] = isset($data['displayNames']['scripts']) ? $data['displayNames']['scripts'] : array();
376 376
 				$this->getTypeList($ldn->scripts, $data['displayNames']['scripts']);
377 377
 			}
378 378
 
379
-			if(isset($ldn->territories)) {
379
+			if (isset($ldn->territories)) {
380 380
 				$data['displayNames']['territories'] = isset($data['displayNames']['territories']) ? $data['displayNames']['territories'] : array();
381 381
 				$this->getTypeList($ldn->territories, $data['displayNames']['territories']);
382 382
 			}
383 383
 
384
-			if(isset($ldn->variants)) {
384
+			if (isset($ldn->variants)) {
385 385
 				$data['displayNames']['variants'] = isset($data['displayNames']['variants']) ? $data['displayNames']['variants'] : array();
386 386
 				$this->getTypeList($ldn->variants, $data['displayNames']['variants']);
387 387
 			}
388 388
 
389
-			if(isset($ldn->keys)) {
389
+			if (isset($ldn->keys)) {
390 390
 				$data['displayNames']['keys'] = isset($data['displayNames']['keys']) ? $data['displayNames']['keys'] : array();
391 391
 				$this->getTypeList($ldn->keys, $data['displayNames']['keys']);
392 392
 			}
@@ -397,138 +397,138 @@  discard block
 block discarded – undo
397 397
 			}
398 398
 			*/
399 399
 
400
-			if(isset($ldn->measurementSystemNames)) {
400
+			if (isset($ldn->measurementSystemNames)) {
401 401
 				$data['displayNames']['measurementSystemNames'] = isset($data['displayNames']['measurementSystemNames']) ? $data['displayNames']['measurementSystemNames'] : array();
402 402
 				$this->getTypeList($ldn->measurementSystemNames, $data['displayNames']['measurementSystemNames']);
403 403
 			}
404 404
 		}
405 405
 
406
-		if(isset($ldmlTree->layout->orientation)) {
406
+		if (isset($ldmlTree->layout->orientation)) {
407 407
 			$ori = $ldmlTree->layout->orientation;
408 408
 
409 409
 			$data['layout']['orientation']['lines'] = $ori->getAttribute('lines', $data['layout']['orientation']['lines']);
410 410
 			$data['layout']['orientation']['characters'] = $ori->getAttribute('characters', $data['layout']['orientation']['characters']);
411 411
 		}
412 412
 
413
-		if(isset($ldmlTree->delimiters)) {
413
+		if (isset($ldmlTree->delimiters)) {
414 414
 			$delims = $ldmlTree->delimiters;
415 415
 
416
-			if(isset($delims->quotationStart)) {
416
+			if (isset($delims->quotationStart)) {
417 417
 				$data['delimiters']['quotationStart'] = $this->unescape($delims->quotationStart->getValue());
418 418
 			}
419
-			if(isset($delims->quotationEnd)) {
419
+			if (isset($delims->quotationEnd)) {
420 420
 				$data['delimiters']['quotationEnd'] = $this->unescape($delims->quotationEnd->getValue());
421 421
 			}
422
-			if(isset($delims->alternateQuotationStart)) {
422
+			if (isset($delims->alternateQuotationStart)) {
423 423
 				$data['delimiters']['alternateQuotationStart'] = $this->unescape($delims->alternateQuotationStart->getValue());
424 424
 			}
425
-			if(isset($delims->alternateQuotationEnd)) {
425
+			if (isset($delims->alternateQuotationEnd)) {
426 426
 				$data['delimiters']['alternateQuotationEnd'] = $this->unescape($delims->alternateQuotationEnd->getValue());
427 427
 			}
428 428
 		}
429 429
 
430
-		if(isset($ldmlTree->dates)) {
430
+		if (isset($ldmlTree->dates)) {
431 431
 			$dates = $ldmlTree->dates;
432 432
 
433
-			if(isset($dates->calendars)) {
433
+			if (isset($dates->calendars)) {
434 434
 				$cals = $dates->calendars;
435 435
 
436
-				foreach($cals as $calendar) {
436
+				foreach ($cals as $calendar) {
437 437
 
438
-					if($calendar->getName() == 'default') {
438
+					if ($calendar->getName() == 'default') {
439 439
 						$data['calendars']['default'] = $calendar->getAttribute('choice');
440
-					} elseif($calendar->getName() == 'calendar') {
440
+					} elseif ($calendar->getName() == 'calendar') {
441 441
 						$calendarName = $calendar->getAttribute('type');
442 442
 
443
-						if(!isset($data['calendars'][$calendarName])) {
443
+						if (!isset($data['calendars'][$calendarName])) {
444 444
 							$data['calendars'][$calendarName] = array();
445 445
 						}
446 446
 
447
-						if(isset($calendar->months)) {
447
+						if (isset($calendar->months)) {
448 448
 							$this->getCalendarWidth($calendar->months, 'month', $data['calendars'][$calendarName]);
449 449
 						}
450 450
 
451
-						if(isset($calendar->days)) {
451
+						if (isset($calendar->days)) {
452 452
 							$this->getCalendarWidth($calendar->days, 'day', $data['calendars'][$calendarName]);
453 453
 						}
454 454
 
455
-						if(isset($calendar->quarters)) {
455
+						if (isset($calendar->quarters)) {
456 456
 							$this->getCalendarWidth($calendar->quarters, 'quarter', $data['calendars'][$calendarName]);
457 457
 						}
458 458
 
459
-						if(isset($calendar->am)) {
459
+						if (isset($calendar->am)) {
460 460
 							$data['calendars'][$calendarName]['am'] = $this->unescape($calendar->am->getValue());
461 461
 						}
462
-						if(isset($calendar->pm)) {
462
+						if (isset($calendar->pm)) {
463 463
 							$data['calendars'][$calendarName]['pm'] = $this->unescape($calendar->pm->getValue());
464 464
 						}
465 465
 
466
-						if(isset($calendar->eras)) {
467
-							if(isset($calendar->eras->eraNames)) {
468
-								foreach($this->getChildsOrAlias($calendar->eras->eraNames) as $era) {
466
+						if (isset($calendar->eras)) {
467
+							if (isset($calendar->eras->eraNames)) {
468
+								foreach ($this->getChildsOrAlias($calendar->eras->eraNames) as $era) {
469 469
 									$data['calendars'][$calendarName]['eras']['wide'][$era->getAttribute('type')] = $this->unescape($era->getValue());
470 470
 								}
471 471
 							}
472
-							if(isset($calendar->eras->eraAbbr)) {
473
-								foreach($this->getChildsOrAlias($calendar->eras->eraAbbr) as $era) {
472
+							if (isset($calendar->eras->eraAbbr)) {
473
+								foreach ($this->getChildsOrAlias($calendar->eras->eraAbbr) as $era) {
474 474
 									$data['calendars'][$calendarName]['eras']['abbreviated'][$era->getAttribute('type')] = $this->unescape($era->getValue());
475 475
 								}
476 476
 							}
477
-							if(isset($calendar->eras->eraNarrow)) {
478
-								foreach($this->getChildsOrAlias($calendar->eras->eraNarrow) as $era) {
477
+							if (isset($calendar->eras->eraNarrow)) {
478
+								foreach ($this->getChildsOrAlias($calendar->eras->eraNarrow) as $era) {
479 479
 									$data['calendars'][$calendarName]['eras']['narrow'][$era->getAttribute('type')] = $this->unescape($era->getValue());
480 480
 								}
481 481
 							}
482 482
 						}
483 483
 
484
-						if(isset($calendar->dateFormats)) {
484
+						if (isset($calendar->dateFormats)) {
485 485
 							$this->getDateOrTimeFormats($calendar->dateFormats, 'dateFormat', $data['calendars'][$calendarName]);
486 486
 						}
487
-						if(isset($calendar->timeFormats)) {
487
+						if (isset($calendar->timeFormats)) {
488 488
 							$this->getDateOrTimeFormats($calendar->timeFormats, 'timeFormat', $data['calendars'][$calendarName]);
489 489
 						}
490 490
 
491
-						if(isset($calendar->dateTimeFormats)) {
491
+						if (isset($calendar->dateTimeFormats)) {
492 492
 							$dtf = $calendar->dateTimeFormats;
493 493
 							$data['calendars'][$calendarName]['dateTimeFormats']['default'] = isset($dtf->default) ? $dtf->default->getAttribute('choice') : '__default';
494 494
 
495 495
 							$dtfItems = $this->getChildsOrAlias($dtf);
496
-							foreach($dtfItems as $item) {
497
-								if($item->getName() == 'dateTimeFormatLength') {
498
-									if(isset($item->dateTimeFormat->pattern)) {
496
+							foreach ($dtfItems as $item) {
497
+								if ($item->getName() == 'dateTimeFormatLength') {
498
+									if (isset($item->dateTimeFormat->pattern)) {
499 499
 										$data['calendars'][$calendarName]['dateTimeFormats']['formats'][$item->getAttribute('type', '__default')] = $this->unescape($item->dateTimeFormat->pattern->getValue(), true);
500 500
 									} else {
501 501
 										throw new AgaviException('unknown child content in dateTimeFormatLength tag');
502 502
 									}
503
-								} elseif($item->getName() == 'availableFormats') {
504
-									foreach($item as $dateFormatItem) {
505
-										if($dateFormatItem->getName() != 'dateFormatItem') {
503
+								} elseif ($item->getName() == 'availableFormats') {
504
+									foreach ($item as $dateFormatItem) {
505
+										if ($dateFormatItem->getName() != 'dateFormatItem') {
506 506
 											throw new AgaviException('unknown childtag "' . $dateFormatItem->getName() . '" in availableFormats tag');
507 507
 										}
508 508
 										$data['calendars'][$calendarName]['dateTimeFormats']['availableFormats'][$dateFormatItem->getAttribute('id')] = $this->unescape($dateFormatItem->getValue(), true);
509 509
 									}
510
-								} elseif($item->getName() == 'appendItems') {
511
-									foreach($item as $appendItem) {
512
-										if($appendItem->getName() != 'appendItem') {
510
+								} elseif ($item->getName() == 'appendItems') {
511
+									foreach ($item as $appendItem) {
512
+										if ($appendItem->getName() != 'appendItem') {
513 513
 											throw new AgaviException('unknown childtag "' . $appendItem->getName() . '" in appendItems tag');
514 514
 										}
515 515
 										$data['calendars'][$calendarName]['dateTimeFormats']['appendItems'][$appendItem->getAttribute('request')] = $this->unescape($appendItem->getValue(), true);
516 516
 									}
517
-								} elseif($item->getName() != 'default') {
517
+								} elseif ($item->getName() != 'default') {
518 518
 									throw new AgaviException('unknown childtag "' . $item->getName() . '" in dateTimeFormats tag');
519 519
 								}
520 520
 							}
521 521
 						}
522 522
 
523
-						if(isset($calendar->fields)) {
524
-							foreach($this->getChildsOrAlias($calendar->fields) as $field) {
523
+						if (isset($calendar->fields)) {
524
+							foreach ($this->getChildsOrAlias($calendar->fields) as $field) {
525 525
 								$type = $field->getAttribute('type');
526
-								if(isset($field->displayName)) {
526
+								if (isset($field->displayName)) {
527 527
 									$data['calendars'][$calendarName]['fields'][$type]['displayName'] = $this->unescape($field->displayName->getValue());
528 528
 								}
529
-								if(isset($field->relative)) {
530
-									foreach($field as $relative) {
531
-										if($relative->getName() == 'relative') {
529
+								if (isset($field->relative)) {
530
+									foreach ($field as $relative) {
531
+										if ($relative->getName() == 'relative') {
532 532
 											$data['calendars'][$calendarName]['fields'][$type]['relatives'][$relative->getAttribute('type')] = $this->unescape($relative->getValue());
533 533
 										}
534 534
 									}
@@ -541,52 +541,52 @@  discard block
 block discarded – undo
541 541
 				}
542 542
 			}
543 543
 			
544
-			if(isset($dates->timeZoneNames)) {
544
+			if (isset($dates->timeZoneNames)) {
545 545
 				$tzn = $dates->timeZoneNames;
546
-				if(isset($tzn->hourFormat)) {
546
+				if (isset($tzn->hourFormat)) {
547 547
 					$data['timeZoneNames']['hourFormat'] = $this->unescape($tzn->hourFormat->getValue());
548 548
 				}
549
-				if(isset($tzn->hoursFormat)) {
549
+				if (isset($tzn->hoursFormat)) {
550 550
 					$data['timeZoneNames']['hoursFormat'] = $this->unescape($tzn->hoursFormat->getValue());
551 551
 				}
552
-				if(isset($tzn->gmtFormat)) {
552
+				if (isset($tzn->gmtFormat)) {
553 553
 					$data['timeZoneNames']['gmtFormat'] = $this->unescape($tzn->gmtFormat->getValue());
554 554
 				}
555
-				if(isset($tzn->regionFormat)) {
555
+				if (isset($tzn->regionFormat)) {
556 556
 					$data['timeZoneNames']['regionFormat'] = $this->unescape($tzn->regionFormat->getValue());
557 557
 				}
558
-				if(isset($tzn->fallbackFormat)) {
558
+				if (isset($tzn->fallbackFormat)) {
559 559
 					$data['timeZoneNames']['fallbackFormat'] = $this->unescape($tzn->fallbackFormat->getValue());
560 560
 				}
561
-				if(isset($tzn->abbreviationFallback)) {
561
+				if (isset($tzn->abbreviationFallback)) {
562 562
 					$data['timeZoneNames']['abbreviationFallback'] = $tzn->abbreviationFallback->getAttribute('choice');
563 563
 				}
564
-				if(isset($tzn->singleCountries)) {
564
+				if (isset($tzn->singleCountries)) {
565 565
 					$data['timeZoneNames']['singleCountries'] = explode(' ', $tzn->singleCountries->getAttribute('list'));
566 566
 				}
567 567
 
568
-				foreach($tzn as $zone) {
568
+				foreach ($tzn as $zone) {
569 569
 					$zoneName = $zone->getAttribute('type');
570
-					if($zone->getName() == 'zone') {
571
-						if(isset($zone->long->generic)) {
570
+					if ($zone->getName() == 'zone') {
571
+						if (isset($zone->long->generic)) {
572 572
 							$data['timeZoneNames']['zones'][$zoneName]['long']['generic'] = $this->unescape($zone->long->generic->getValue());
573 573
 						}
574
-						if(isset($zone->long->standard)) {
574
+						if (isset($zone->long->standard)) {
575 575
 							$data['timeZoneNames']['zones'][$zoneName]['long']['standard'] = $this->unescape($zone->long->standard->getValue());
576 576
 						}
577
-						if(isset($zone->long->daylight)) {
577
+						if (isset($zone->long->daylight)) {
578 578
 							$data['timeZoneNames']['zones'][$zoneName]['long']['daylight'] = $this->unescape($zone->long->daylight->getValue());
579 579
 						}
580
-						if(isset($zone->short->generic)) {
580
+						if (isset($zone->short->generic)) {
581 581
 							$data['timeZoneNames']['zones'][$zoneName]['short']['generic'] = $this->unescape($zone->short->generic->getValue());
582 582
 						}
583
-						if(isset($zone->short->standard)) {
583
+						if (isset($zone->short->standard)) {
584 584
 							$data['timeZoneNames']['zones'][$zoneName]['short']['standard'] = $this->unescape($zone->short->standard->getValue());
585 585
 						}
586
-						if(isset($zone->short->daylight)) {
586
+						if (isset($zone->short->daylight)) {
587 587
 							$data['timeZoneNames']['zones'][$zoneName]['short']['daylight'] = $this->unescape($zone->short->daylight->getValue());
588 588
 						}
589
-						if(isset($zone->exemplarCity)) {
589
+						if (isset($zone->exemplarCity)) {
590 590
 							$data['timeZoneNames']['zones'][$zoneName]['exemplarCity'] = $this->unescape($zone->exemplarCity->getValue());
591 591
 						}
592 592
 
@@ -595,72 +595,72 @@  discard block
 block discarded – undo
595 595
 			}
596 596
 		}
597 597
 
598
-		if(isset($ldmlTree->numbers)) {
598
+		if (isset($ldmlTree->numbers)) {
599 599
 			$nums = $ldmlTree->numbers;
600
-			if(!isset($data['numbers'])) {
600
+			if (!isset($data['numbers'])) {
601 601
 				$data['numbers'] = array();
602 602
 			}
603 603
 
604
-			if(isset($nums->symbols)) {
604
+			if (isset($nums->symbols)) {
605 605
 				$syms = $nums->symbols;
606
-				if(isset($syms->decimal)) {
606
+				if (isset($syms->decimal)) {
607 607
 					$data['numbers']['symbols']['decimal'] = $this->unescape($syms->decimal->getValue());
608 608
 				}
609
-				if(isset($syms->group)) {
609
+				if (isset($syms->group)) {
610 610
 					$data['numbers']['symbols']['group'] = $this->unescape($syms->group->getValue());
611 611
 				}
612
-				if(isset($syms->list)) {
612
+				if (isset($syms->list)) {
613 613
 					$data['numbers']['symbols']['list'] = $this->unescape($syms->list->getValue());
614 614
 				}
615
-				if(isset($syms->percentSign)) {
615
+				if (isset($syms->percentSign)) {
616 616
 					$data['numbers']['symbols']['percentSign'] = $this->unescape($syms->percentSign->getValue());
617 617
 				}
618
-				if(isset($syms->nativeZeroDigit)) {
618
+				if (isset($syms->nativeZeroDigit)) {
619 619
 					$data['numbers']['symbols']['nativeZeroDigit'] = $this->unescape($syms->nativeZeroDigit->getValue());
620 620
 				}
621
-				if(isset($syms->patternDigit)) {
621
+				if (isset($syms->patternDigit)) {
622 622
 					$data['numbers']['symbols']['patternDigit'] = $this->unescape($syms->patternDigit->getValue());
623 623
 				}
624
-				if(isset($syms->plusSign)) {
624
+				if (isset($syms->plusSign)) {
625 625
 					$data['numbers']['symbols']['plusSign'] = $this->unescape($syms->plusSign->getValue());
626 626
 				}
627
-				if(isset($syms->minusSign)) {
627
+				if (isset($syms->minusSign)) {
628 628
 					$data['numbers']['symbols']['minusSign'] = $this->unescape($syms->minusSign->getValue());
629 629
 				}
630
-				if(isset($syms->exponential)) {
630
+				if (isset($syms->exponential)) {
631 631
 					$data['numbers']['symbols']['exponential'] = $this->unescape($syms->exponential->getValue());
632 632
 				}
633
-				if(isset($syms->perMille)) {
633
+				if (isset($syms->perMille)) {
634 634
 					$data['numbers']['symbols']['perMille'] = $this->unescape($syms->perMille->getValue());
635 635
 				}
636
-				if(isset($syms->infinity)) {
636
+				if (isset($syms->infinity)) {
637 637
 					$data['numbers']['symbols']['infinity'] = $this->unescape($syms->infinity->getValue());
638 638
 				}
639
-				if(isset($syms->nan)) {
639
+				if (isset($syms->nan)) {
640 640
 					$data['numbers']['symbols']['nan'] = $this->unescape($syms->nan->getValue());
641 641
 				}
642 642
 			}
643
-			if(isset($nums->decimalFormats)) {
643
+			if (isset($nums->decimalFormats)) {
644 644
 				$this->getNumberFormats($nums->decimalFormats, 'decimalFormat', $data['numbers']);
645 645
 			}
646
-			if(isset($nums->scientificFormats)) {
646
+			if (isset($nums->scientificFormats)) {
647 647
 				$this->getNumberFormats($nums->scientificFormats, 'scientificFormat', $data['numbers']);
648 648
 			}
649
-			if(isset($nums->percentFormats)) {
649
+			if (isset($nums->percentFormats)) {
650 650
 				$this->getNumberFormats($nums->percentFormats, 'percentFormat', $data['numbers']);
651 651
 			}
652
-			if(isset($nums->currencyFormats)) {
652
+			if (isset($nums->currencyFormats)) {
653 653
 				$cf = $nums->currencyFormats;
654 654
 
655
-				foreach($this->getChildsOrAlias($cf) as $itemLength) {
656
-					if($itemLength->getName() == 'default') {
655
+				foreach ($this->getChildsOrAlias($cf) as $itemLength) {
656
+					if ($itemLength->getName() == 'default') {
657 657
 						$data['numbers']['currencyFormats']['default'] = $itemLength->getAttribute('choice');
658
-					} elseif($itemLength->getName() == 'currencyFormatLength') {
658
+					} elseif ($itemLength->getName() == 'currencyFormatLength') {
659 659
 						$itemLengthName = $itemLength->getAttribute('type', '__default');
660 660
 
661
-						foreach($this->getChildsOrAlias($itemLength) as $itemFormat) {
662
-							if($itemFormat->getName() == 'currencyFormat') {
663
-								if(isset($itemFormat->pattern)) {
661
+						foreach ($this->getChildsOrAlias($itemLength) as $itemFormat) {
662
+							if ($itemFormat->getName() == 'currencyFormat') {
663
+								if (isset($itemFormat->pattern)) {
664 664
 									$data['numbers']['currencyFormats'][$itemLengthName] = $this->unescape($itemFormat->pattern->getValue());
665 665
 								}
666 666
 							} else {
@@ -668,24 +668,24 @@  discard block
 block discarded – undo
668 668
 							}
669 669
 
670 670
 						}
671
-					} elseif($itemLength->getName() == 'currencySpacing') {
671
+					} elseif ($itemLength->getName() == 'currencySpacing') {
672 672
 
673
-						if(isset($itemLength->beforeCurrency->currencyMatch)) {
673
+						if (isset($itemLength->beforeCurrency->currencyMatch)) {
674 674
 							$data['numbers']['currencySpacing']['beforeCurrency']['currencyMatch'] = $this->unescape($itemLength->beforeCurrency->currencyMatch->getValue());
675 675
 						}
676
-						if(isset($itemLength->beforeCurrency->surroundingMatch)) {
676
+						if (isset($itemLength->beforeCurrency->surroundingMatch)) {
677 677
 							$data['numbers']['currencySpacing']['beforeCurrency']['surroundingMatch'] = $this->unescape($itemLength->beforeCurrency->surroundingMatch->getValue());
678 678
 						}
679
-						if(isset($itemLength->beforeCurrency->insertBetween)) {
679
+						if (isset($itemLength->beforeCurrency->insertBetween)) {
680 680
 							$data['numbers']['currencySpacing']['beforeCurrency']['insertBetween'] = $this->unescape($itemLength->beforeCurrency->insertBetween->getValue());
681 681
 						}
682
-						if(isset($itemLength->afterCurrency->currencyMatch)) {
682
+						if (isset($itemLength->afterCurrency->currencyMatch)) {
683 683
 							$data['numbers']['currencySpacing']['afterCurrency']['currencyMatch'] = $this->unescape($itemLength->afterCurrency->currencyMatch->getValue());
684 684
 						}
685
-						if(isset($itemLength->afterCurrency->surroundingMatch)) {
685
+						if (isset($itemLength->afterCurrency->surroundingMatch)) {
686 686
 							$data['numbers']['currencySpacing']['afterCurrency']['surroundingMatch'] = $this->unescape($itemLength->afterCurrency->surroundingMatch->getValue());
687 687
 						}
688
-						if(isset($itemLength->afterCurrency->insertBetween)) {
688
+						if (isset($itemLength->afterCurrency->insertBetween)) {
689 689
 							$data['numbers']['currencySpacing']['afterCurrency']['insertBetween'] = $this->unescape($itemLength->afterCurrency->insertBetween->getValue());
690 690
 						}
691 691
 
@@ -694,15 +694,15 @@  discard block
 block discarded – undo
694 694
 					}
695 695
 				}
696 696
 			}
697
-			if(isset($nums->currencies)) {
698
-				foreach($nums->currencies as $currency) {
697
+			if (isset($nums->currencies)) {
698
+				foreach ($nums->currencies as $currency) {
699 699
 					$name = $currency->getAttribute('type');
700
-					if(isset($currency->displayName)) {
700
+					if (isset($currency->displayName)) {
701 701
 						$data['numbers']['currencies'][$name]['displayName'] = $this->unescape($currency->displayName->getValue());
702 702
 					}
703
-					if(isset($currency->symbol)) {
703
+					if (isset($currency->symbol)) {
704 704
 						$symbolValue = $this->unescape($currency->symbol->getValue());
705
-						if($currency->symbol->getAttribute('choice') == 'true') {
705
+						if ($currency->symbol->getAttribute('choice') == 'true') {
706 706
 							$symbolValue = explode('|', $symbolValue);
707 707
 						}
708 708
 						$data['numbers']['currencies'][$name]['symbol'] = $symbolValue;
@@ -729,17 +729,17 @@  discard block
 block discarded – undo
729 729
 	{
730 730
 		// debug stuff to check if we missed any tags (lc = loop count)
731 731
 		$lc = 0;
732
-		foreach($list as $listItem) {
732
+		foreach ($list as $listItem) {
733 733
 			$type = $listItem->getAttribute('type');
734 734
 
735
-			if(!$listItem->hasAttribute('alt')) {
735
+			if (!$listItem->hasAttribute('alt')) {
736 736
 				$data[$type] = $this->unescape($listItem->getValue());
737 737
 			}
738 738
 
739 739
 			++$lc;
740 740
 		}
741 741
 
742
-		if($lc != count($list->getChildren())) {
742
+		if ($lc != count($list->getChildren())) {
743 743
 			throw new AgaviException('wrong tagcount');
744 744
 		}
745 745
 
@@ -763,25 +763,25 @@  discard block
 block discarded – undo
763 763
 		$dataIdxName = $name . 's';
764 764
 
765 765
 		$items = $this->getChildsOrAlias($item);
766
-		foreach($items as $itemContext) {
767
-			if($itemContext->getName() == 'default') {
766
+		foreach ($items as $itemContext) {
767
+			if ($itemContext->getName() == 'default') {
768 768
 				$data[$dataIdxName]['default'] = $itemContext->getAttribute('choice');
769
-			} elseif($itemContext->getName() == $name . 'Context') {
769
+			} elseif ($itemContext->getName() == $name . 'Context') {
770 770
 				$itemContextName = $itemContext->getAttribute('type');
771 771
 
772
-				foreach($itemContext as $itemWidths) {
773
-					if($itemWidths->getName() == 'default') {
772
+				foreach ($itemContext as $itemWidths) {
773
+					if ($itemWidths->getName() == 'default') {
774 774
 						$data[$dataIdxName][$itemContextName]['default'] = $itemWidths->getAttribute('choice');
775
-					} elseif($itemWidths->getName() == $name . 'Width') {
775
+					} elseif ($itemWidths->getName() == $name . 'Width') {
776 776
 						$itemWidthName = $itemWidths->getAttribute('type');
777 777
 
778 778
 						$widthChildItems = $this->getChildsOrAlias($itemWidths);
779
-						foreach($widthChildItems as $item) {
780
-							if($item->getName() != $name) {
779
+						foreach ($widthChildItems as $item) {
780
+							if ($item->getName() != $name) {
781 781
 								throw new AgaviException('unknown childtag "' . $item->getName() . '" in ' . $name . 'Widths tag');
782 782
 							}
783 783
 
784
-							if(!$item->hasAttribute('alt')) {
784
+							if (!$item->hasAttribute('alt')) {
785 785
 								$itemName = $item->getAttribute('type');
786 786
 								$data[$dataIdxName][$itemContextName][$itemWidthName][$itemName] = $this->unescape($item->getValue());
787 787
 							}
@@ -814,19 +814,19 @@  discard block
 block discarded – undo
814 814
 		$dataIdxName = $name . 's';
815 815
 
816 816
 		$items = $this->getChildsOrAlias($item);
817
-		foreach($items as $itemLength) {
818
-			if($itemLength->getName() == 'default') {
817
+		foreach ($items as $itemLength) {
818
+			if ($itemLength->getName() == 'default') {
819 819
 				$data[$dataIdxName]['default'] = $itemLength->getAttribute('choice');
820
-			} elseif($itemLength->getName() == $name . 'Length') {
820
+			} elseif ($itemLength->getName() == $name . 'Length') {
821 821
 				$itemLengthName = $itemLength->getAttribute('type', '__default');
822 822
 
823 823
 				$aliasedItemLength = $this->getChildsOrAlias($itemLength);
824
-				foreach($aliasedItemLength as $itemFormat) {
825
-					if($itemFormat->getName() == $name) {
826
-						if(isset($itemFormat->pattern)) {
824
+				foreach ($aliasedItemLength as $itemFormat) {
825
+					if ($itemFormat->getName() == $name) {
826
+						if (isset($itemFormat->pattern)) {
827 827
 							$data[$dataIdxName][$itemLengthName]['pattern'] = $this->unescape($itemFormat->pattern->getValue(), true);
828 828
 						}
829
-						if(isset($itemFormat->displayName)) {
829
+						if (isset($itemFormat->displayName)) {
830 830
 							$data[$dataIdxName][$itemLengthName]['displayName'] = $this->unescape($itemFormat->displayName->getValue());
831 831
 						}
832 832
 					} else {
@@ -857,15 +857,15 @@  discard block
 block discarded – undo
857 857
 		$dataIdxName = $name . 's';
858 858
 
859 859
 		$items = $this->getChildsOrAlias($item);
860
-		foreach($items as $itemLength) {
861
-			if($itemLength->getName() == 'default') {
860
+		foreach ($items as $itemLength) {
861
+			if ($itemLength->getName() == 'default') {
862 862
 				$data[$dataIdxName]['default'] = $itemLength->getAttribute('choice');
863
-			} elseif($itemLength->getName() == $name . 'Length') {
863
+			} elseif ($itemLength->getName() == $name . 'Length') {
864 864
 				$itemLengthName = $itemLength->getAttribute('type', '__default');
865 865
 
866
-				foreach($this->getChildsOrAlias($itemLength) as $itemFormat) {
867
-					if($itemFormat->getName() == $name) {
868
-						if(isset($itemFormat->pattern)) {
866
+				foreach ($this->getChildsOrAlias($itemLength) as $itemFormat) {
867
+					if ($itemFormat->getName() == $name) {
868
+						if (isset($itemFormat->pattern)) {
869 869
 							$data[$dataIdxName][$itemLengthName] = $this->unescape($itemFormat->pattern->getValue());
870 870
 						}
871 871
 					} else {
@@ -892,9 +892,9 @@  discard block
 block discarded – undo
892 892
 	 */
893 893
 	protected function getChildsOrAlias(ConfigValueHolder $item)
894 894
 	{
895
-		if(isset($item->alias)) {
895
+		if (isset($item->alias)) {
896 896
 			$alias = $item->alias;
897
-			if($alias->getAttribute('source') != 'locale') {
897
+			if ($alias->getAttribute('source') != 'locale') {
898 898
 				throw new AgaviException('The alias handling doesn\'t support any source except locale (' . $alias->getAttribute('source') . ' was given)');
899 899
 			}
900 900
 
@@ -902,14 +902,14 @@  discard block
 block discarded – undo
902 902
 
903 903
 			$currentNodeId = $item->getAttribute('__agavi_node_id');
904 904
 			
905
-			foreach($pathParts as $part) {
905
+			foreach ($pathParts as $part) {
906 906
 				// select the parent node
907
-				if($part == '..') {
907
+				if ($part == '..') {
908 908
 					$currentNodeId = $this->nodeRefs[$currentNodeId]->getAttribute('__agavi_parent_id');
909 909
 				} else {
910 910
 					$predicates = array();
911
-					if(preg_match('#([^\[]+)\[([^\]]+)\]#', $part, $match)) {
912
-						if(!preg_match('#@([^=]+)=\'([^\']+)\'#', $match[2], $predMatch)) {
911
+					if (preg_match('#([^\[]+)\[([^\]]+)\]#', $part, $match)) {
912
+						if (!preg_match('#@([^=]+)=\'([^\']+)\'#', $match[2], $predMatch)) {
913 913
 							throw new AgaviException('Unknown predicate ' . $match[2] . ' in alias xpath spec');
914 914
 						}
915 915
 						$tagName = $match[1];
@@ -917,21 +917,21 @@  discard block
 block discarded – undo
917 917
 					} else {
918 918
 						$tagName = $part;
919 919
 					}
920
-					foreach($this->nodeRefs[$currentNodeId]->getChildren() as $childNode) {
920
+					foreach ($this->nodeRefs[$currentNodeId]->getChildren() as $childNode) {
921 921
 						$isSearchedNode = false;
922
-						if($childNode->getName() == $tagName) {
922
+						if ($childNode->getName() == $tagName) {
923 923
 							$predMatches = 0;
924
-							foreach($predicates as $attrib => $value) {
925
-								if($childNode->getAttribute($attrib) == $value) {
924
+							foreach ($predicates as $attrib => $value) {
925
+								if ($childNode->getAttribute($attrib) == $value) {
926 926
 									++$predMatches;
927 927
 								}
928 928
 							}
929
-							if($predMatches == count($predicates)) {
929
+							if ($predMatches == count($predicates)) {
930 930
 								$isSearchedNode = true;
931 931
 							}
932 932
 						}
933 933
 
934
-						if($isSearchedNode) {
934
+						if ($isSearchedNode) {
935 935
 							$currentNodeId = $childNode->getAttribute('__agavi_node_id');
936 936
 						}
937 937
 					}
@@ -961,18 +961,18 @@  discard block
 block discarded – undo
961 961
 	{
962 962
 		$output = '';
963 963
 		$hex = '[0-9A-Fa-f]';
964
-		$rx = '\\\\(\\\\|u' . $hex . '{4}|U' . $hex . '{8}|x' . $hex .'{1,2}|[0-7]{1,3}|.)';
965
-		if($handleQuotes) {
964
+		$rx = '\\\\(\\\\|u' . $hex . '{4}|U' . $hex . '{8}|x' . $hex . '{1,2}|[0-7]{1,3}|.)';
965
+		if ($handleQuotes) {
966 966
 			// needs to be < -1 to not confuse the algorithm in the first run
967 967
 			$lastClose = -2;
968
-			if(preg_match_all("#'(?:''|[^'])+'|" . $rx . "#", $input, $matches, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE)) {
968
+			if (preg_match_all("#'(?:''|[^'])+'|" . $rx . "#", $input, $matches, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE)) {
969 969
 				$output = $input;
970 970
 				$offsetMod = 0;
971 971
 				$ml = $matches[0];
972 972
 				$len = count($ml);
973
-				for($i = 0; $i < $len; ++ $i) {
973
+				for ($i = 0; $i < $len; ++ $i) {
974 974
 					$match = $ml[$i];
975
-					if($match[0][0] != '\'') {
975
+					if ($match[0][0] != '\'') {
976 976
 						// we check if there is a quoted string directly before or directly after the escape sequence
977 977
 						// by using the string lengths and the offset of the matches. Since an escape sequence directly before
978 978
 						// this sequence results in an quoted string we only check if its really a quoted string and not an
@@ -982,7 +982,7 @@  discard block
 block discarded – undo
982 982
 						$oldLen = strlen($output);
983 983
 						$unescaped = $this->unescapeCallback(array($match[0], substr($match[0], 1)));
984 984
 						$unescaped = ($quoteBefore ? '' : '\'') . $unescaped . ($quoteAfter ? '' : '\'');
985
-						$replacedPartLen = strlen($match[0]) + ((int) $quoteBefore) + ((int) $quoteAfter);
985
+						$replacedPartLen = strlen($match[0]) + ((int)$quoteBefore) + ((int)$quoteAfter);
986 986
 						// replace the matched escape sequence with the unescaped one. we also replace the opening or closing quote
987 987
 						// from the quoted part before or after this escape sequence to include the unescaped string into the closed part
988 988
 						$output = substr_replace($output, $unescaped, $offsetMod + $match[1] + ($quoteBefore ? -1 : 0), $replacedPartLen);
@@ -1029,11 +1029,11 @@  discard block
 block discarded – undo
1029 1029
 		
1030 1030
 		$char = $matches[1][0];
1031 1031
 		$seq = substr($matches[1], 1);
1032
-		if($char == 'u' || $char == 'U' || $char == 'x') {
1032
+		if ($char == 'u' || $char == 'U' || $char == 'x') {
1033 1033
 			$res = html_entity_decode('&#x' . $seq . ';', ENT_QUOTES, 'utf-8');
1034
-		} elseif(is_numeric($char)) {
1034
+		} elseif (is_numeric($char)) {
1035 1035
 			$res = html_entity_decode('&#' . octdec($matches[1]) . ';', ENT_QUOTES, 'utf-8');
1036
-		} elseif(isset($map[$char])) {
1036
+		} elseif (isset($map[$char])) {
1037 1037
 			$res = $map[$char];
1038 1038
 		} else {
1039 1039
 			$res = $char; // something like \s or \0 or so, just return the character ("s" or "0")
Please login to merge, or discard this patch.
Indentation   +821 added lines, -821 removed lines patch added patch discarded remove patch
@@ -34,135 +34,135 @@  discard block
 block discarded – undo
34 34
  */
35 35
 class LdmlConfigHandler extends ConfigHandler
36 36
 {
37
-	protected $nodeRefs = array();
38
-
39
-	/**
40
-	 * Execute this configuration handler.
41
-	 *
42
-	 * @param      string $config  An absolute filesystem path to a configuration file.
43
-	 * @param      string $context An optional context in which we are currently running.
44
-	 *
45
-	 * @return     string Data to be written to a cache file.
46
-	 *
47
-	 * @throws     <b>AgaviUnreadableException</b> If a requested configuration
48
-	 *                                             file does not exist or is not
49
-	 *                                             readable.
50
-	 * @throws     <b>AgaviParseException</b> If a requested configuration file is
51
-	 *                                        improperly formatted.
52
-	 *
53
-	 * @author     Dominik del Bondio <[email protected]>
54
-	 * @since      0.11.0
55
-	 */
56
-	public function execute($config, $context = null)
57
-	{
58
-		$pathParts = pathinfo($config);
59
-		// unlike basename, filename does not contain the extension, which is what we need there
60
-		$lookupPaths = Locale::getLookupPath($pathParts['filename']);
61
-		$lookupPaths[] = 'root';
62
-
63
-		$data = array(
64
-			'layout' => array('orientation' => array('lines' => 'top-to-bottom', 'characters' => 'left-to-right')),
65
-		);
66
-
67
-		foreach(array_reverse($lookupPaths) as $basename) {
68
-			$filePath = $pathParts['dirname'] . '/' . $basename . '.' . $pathParts['extension'];
69
-			if(is_readable($filePath)) {
70
-				$ldmlTree = ConfigCache::parseConfig($filePath, false, $this->getValidationFile(), $this->parser);
71
-				$this->prepareParentInformation($ldmlTree);
72
-				$this->parseLdmlTree($ldmlTree->ldml, $data);
73
-			}
74
-		}
75
-
76
-		$dayMap = array(
77
-										'sun' => DateDefinitions::SUNDAY,
78
-										'mon' => DateDefinitions::MONDAY,
79
-										'tue' => DateDefinitions::TUESDAY,
80
-										'wed' => DateDefinitions::WEDNESDAY,
81
-										'thu' => DateDefinitions::THURSDAY,
82
-										'fri' => DateDefinitions::FRIDAY,
83
-										'sat' => DateDefinitions::SATURDAY,
84
-		);
85
-
86
-		// fix the day indices for all day fields
87
-		foreach($data['calendars'] as $calKey => &$calValue) {
88
-			// skip the 'default' => '' key => value pair
89
-			if(is_array($calValue)) {
90
-				if(isset($calValue['days']['format'])) {
91
-					foreach($calValue['days']['format'] as $formatKey => &$formatValue) {
92
-						if(is_array($formatValue)) {
93
-							$newData = array();
94
-							foreach($formatValue as $day => $value) {
95
-								$newData[$dayMap[$day]] = $value;
96
-							}
97
-							$formatValue = $newData;
98
-						}
99
-					}
100
-				}
101
-
102
-				if(isset($calValue['days']['stand-alone'])) {
103
-					foreach($calValue['days']['stand-alone'] as $formatKey => &$formatValue) {
104
-						if(is_array($formatValue)) {
105
-							$newData = array();
106
-							foreach($formatValue as $day => $value) {
107
-								$newData[$dayMap[$day]] = $value;
108
-							}
109
-							$formatValue = $newData;
110
-						}
111
-					}
112
-				}
113
-			}
114
-		}
115
-
116
-		$code = array();
117
-		$code[] = 'return ' . var_export($data, true) . ';';
118
-
119
-		return $this->generate($code, $config);
120
-	}
121
-
122
-	/**
123
-	 * Prepares the parent information for the given ldml tree.
124
-	 *
125
-	 * @param      ConfigValueHolder $ldmlTree The ldml tree.
126
-	 *
127
-	 * @author     Dominik del Bondio <[email protected]>
128
-	 * @since      0.11.0
129
-	 */
130
-	protected function prepareParentInformation($ldmlTree)
131
-	{
132
-		$this->nodeRefs = array();
133
-		$i = 0;
134
-		$ldmlTree->setAttribute('__agavi_node_id', $i);
135
-		$ldmlTree->setAttribute('__agavi_parent_id', null);
136
-		$this->nodeRefs[$i] = $ldmlTree;
137
-		++$i;
138
-		if($ldmlTree->hasChildren()) {
139
-			$this->generateParentInformation($ldmlTree->getChildren(), $i, 0);
140
-		}
141
-	}
142
-
143
-	/**
144
-	 * Generates the parent information for the given ldml subtree.
145
-	 *
146
-	 * @param      ConfigValueHolder[] $childList The ldml node.
147
-	 * @param	   int                 $nextId
148
-	 * @param      int                 $parentId
149
-	 *
150
-	 * @author     Dominik del Bondio <[email protected]>
151
-	 * @since      0.11.0
152
-	 */
153
-	protected function generateParentInformation($childList, &$nextId, $parentId)
154
-	{
155
-		/** @var ConfigValueHolder $child */
156
-		foreach($childList as $child) {
157
-			$child->setAttribute('__agavi_node_id', $nextId);
158
-			$child->setAttribute('__agavi_parent_id', $parentId);
159
-			$this->nodeRefs[$nextId] = $child;
160
-			++$nextId;
161
-			if($child->hasChildren()) {
162
-				$this->generateParentInformation($child->getChildren(), $nextId, $child->getAttribute('__agavi_node_id'));
163
-			}
164
-		}
165
-	}
37
+    protected $nodeRefs = array();
38
+
39
+    /**
40
+     * Execute this configuration handler.
41
+     *
42
+     * @param      string $config  An absolute filesystem path to a configuration file.
43
+     * @param      string $context An optional context in which we are currently running.
44
+     *
45
+     * @return     string Data to be written to a cache file.
46
+     *
47
+     * @throws     <b>AgaviUnreadableException</b> If a requested configuration
48
+     *                                             file does not exist or is not
49
+     *                                             readable.
50
+     * @throws     <b>AgaviParseException</b> If a requested configuration file is
51
+     *                                        improperly formatted.
52
+     *
53
+     * @author     Dominik del Bondio <[email protected]>
54
+     * @since      0.11.0
55
+     */
56
+    public function execute($config, $context = null)
57
+    {
58
+        $pathParts = pathinfo($config);
59
+        // unlike basename, filename does not contain the extension, which is what we need there
60
+        $lookupPaths = Locale::getLookupPath($pathParts['filename']);
61
+        $lookupPaths[] = 'root';
62
+
63
+        $data = array(
64
+            'layout' => array('orientation' => array('lines' => 'top-to-bottom', 'characters' => 'left-to-right')),
65
+        );
66
+
67
+        foreach(array_reverse($lookupPaths) as $basename) {
68
+            $filePath = $pathParts['dirname'] . '/' . $basename . '.' . $pathParts['extension'];
69
+            if(is_readable($filePath)) {
70
+                $ldmlTree = ConfigCache::parseConfig($filePath, false, $this->getValidationFile(), $this->parser);
71
+                $this->prepareParentInformation($ldmlTree);
72
+                $this->parseLdmlTree($ldmlTree->ldml, $data);
73
+            }
74
+        }
75
+
76
+        $dayMap = array(
77
+                                        'sun' => DateDefinitions::SUNDAY,
78
+                                        'mon' => DateDefinitions::MONDAY,
79
+                                        'tue' => DateDefinitions::TUESDAY,
80
+                                        'wed' => DateDefinitions::WEDNESDAY,
81
+                                        'thu' => DateDefinitions::THURSDAY,
82
+                                        'fri' => DateDefinitions::FRIDAY,
83
+                                        'sat' => DateDefinitions::SATURDAY,
84
+        );
85
+
86
+        // fix the day indices for all day fields
87
+        foreach($data['calendars'] as $calKey => &$calValue) {
88
+            // skip the 'default' => '' key => value pair
89
+            if(is_array($calValue)) {
90
+                if(isset($calValue['days']['format'])) {
91
+                    foreach($calValue['days']['format'] as $formatKey => &$formatValue) {
92
+                        if(is_array($formatValue)) {
93
+                            $newData = array();
94
+                            foreach($formatValue as $day => $value) {
95
+                                $newData[$dayMap[$day]] = $value;
96
+                            }
97
+                            $formatValue = $newData;
98
+                        }
99
+                    }
100
+                }
101
+
102
+                if(isset($calValue['days']['stand-alone'])) {
103
+                    foreach($calValue['days']['stand-alone'] as $formatKey => &$formatValue) {
104
+                        if(is_array($formatValue)) {
105
+                            $newData = array();
106
+                            foreach($formatValue as $day => $value) {
107
+                                $newData[$dayMap[$day]] = $value;
108
+                            }
109
+                            $formatValue = $newData;
110
+                        }
111
+                    }
112
+                }
113
+            }
114
+        }
115
+
116
+        $code = array();
117
+        $code[] = 'return ' . var_export($data, true) . ';';
118
+
119
+        return $this->generate($code, $config);
120
+    }
121
+
122
+    /**
123
+     * Prepares the parent information for the given ldml tree.
124
+     *
125
+     * @param      ConfigValueHolder $ldmlTree The ldml tree.
126
+     *
127
+     * @author     Dominik del Bondio <[email protected]>
128
+     * @since      0.11.0
129
+     */
130
+    protected function prepareParentInformation($ldmlTree)
131
+    {
132
+        $this->nodeRefs = array();
133
+        $i = 0;
134
+        $ldmlTree->setAttribute('__agavi_node_id', $i);
135
+        $ldmlTree->setAttribute('__agavi_parent_id', null);
136
+        $this->nodeRefs[$i] = $ldmlTree;
137
+        ++$i;
138
+        if($ldmlTree->hasChildren()) {
139
+            $this->generateParentInformation($ldmlTree->getChildren(), $i, 0);
140
+        }
141
+    }
142
+
143
+    /**
144
+     * Generates the parent information for the given ldml subtree.
145
+     *
146
+     * @param      ConfigValueHolder[] $childList The ldml node.
147
+     * @param	   int                 $nextId
148
+     * @param      int                 $parentId
149
+     *
150
+     * @author     Dominik del Bondio <[email protected]>
151
+     * @since      0.11.0
152
+     */
153
+    protected function generateParentInformation($childList, &$nextId, $parentId)
154
+    {
155
+        /** @var ConfigValueHolder $child */
156
+        foreach($childList as $child) {
157
+            $child->setAttribute('__agavi_node_id', $nextId);
158
+            $child->setAttribute('__agavi_parent_id', $parentId);
159
+            $this->nodeRefs[$nextId] = $child;
160
+            ++$nextId;
161
+            if($child->hasChildren()) {
162
+                $this->generateParentInformation($child->getChildren(), $nextId, $child->getAttribute('__agavi_node_id'));
163
+            }
164
+        }
165
+    }
166 166
 
167 167
 /*
168 168
 
@@ -336,711 +336,711 @@  discard block
 block discarded – undo
336 336
 			
337 337
 */
338 338
 
339
-	/**
340
-	 * Generates the array used by AgaviLocale from an LDML tree.
341
-	 *
342
-	 * @param      ConfigValueHolder $ldmlTree The ldml tree.
343
-	 * @param      array             $data     The array to store the parsed data to.
344
-	 *
345
-	 * @return     array The array with the data.
346
-	 *
347
-	 * @author     Dominik del Bondio <[email protected]>
348
-	 * @since      0.11.0
349
-	 */
350
-	public function parseLdmlTree($ldmlTree, &$data)
351
-	{
352
-
353
-		if(isset($ldmlTree->identity)) {
354
-			$data['locale']['language'] = $ldmlTree->identity->language->getAttribute('type');
355
-			if(isset($ldmlTree->identity->territory)) {
356
-				$data['locale']['territory'] = $ldmlTree->identity->territory->getAttribute('type');
357
-			}
358
-			if(isset($ldmlTree->identity->script)) {
359
-				$data['locale']['script'] = $ldmlTree->identity->script->getAttribute('type');
360
-			}
361
-			if(isset($ldmlTree->identity->variant)) {
362
-				$data['locale']['variant'] = $ldmlTree->identity->variant->getAttribute('type');
363
-			}
364
-		}
365
-
366
-		if(isset($ldmlTree->localeDisplayNames)) {
367
-			$ldn = $ldmlTree->localeDisplayNames;
368
-
369
-			if(isset($ldn->languages)) {
370
-				$data['displayNames']['languages'] = isset($data['displayNames']['languages']) ? $data['displayNames']['languages'] : array();
371
-				$this->getTypeList($ldn->languages, $data['displayNames']['languages']);
372
-			}
373
-
374
-			if(isset($ldn->scripts)) {
375
-				$data['displayNames']['scripts'] = isset($data['displayNames']['scripts']) ? $data['displayNames']['scripts'] : array();
376
-				$this->getTypeList($ldn->scripts, $data['displayNames']['scripts']);
377
-			}
378
-
379
-			if(isset($ldn->territories)) {
380
-				$data['displayNames']['territories'] = isset($data['displayNames']['territories']) ? $data['displayNames']['territories'] : array();
381
-				$this->getTypeList($ldn->territories, $data['displayNames']['territories']);
382
-			}
383
-
384
-			if(isset($ldn->variants)) {
385
-				$data['displayNames']['variants'] = isset($data['displayNames']['variants']) ? $data['displayNames']['variants'] : array();
386
-				$this->getTypeList($ldn->variants, $data['displayNames']['variants']);
387
-			}
388
-
389
-			if(isset($ldn->keys)) {
390
-				$data['displayNames']['keys'] = isset($data['displayNames']['keys']) ? $data['displayNames']['keys'] : array();
391
-				$this->getTypeList($ldn->keys, $data['displayNames']['keys']);
392
-			}
393
-
394
-			/*
339
+    /**
340
+     * Generates the array used by AgaviLocale from an LDML tree.
341
+     *
342
+     * @param      ConfigValueHolder $ldmlTree The ldml tree.
343
+     * @param      array             $data     The array to store the parsed data to.
344
+     *
345
+     * @return     array The array with the data.
346
+     *
347
+     * @author     Dominik del Bondio <[email protected]>
348
+     * @since      0.11.0
349
+     */
350
+    public function parseLdmlTree($ldmlTree, &$data)
351
+    {
352
+
353
+        if(isset($ldmlTree->identity)) {
354
+            $data['locale']['language'] = $ldmlTree->identity->language->getAttribute('type');
355
+            if(isset($ldmlTree->identity->territory)) {
356
+                $data['locale']['territory'] = $ldmlTree->identity->territory->getAttribute('type');
357
+            }
358
+            if(isset($ldmlTree->identity->script)) {
359
+                $data['locale']['script'] = $ldmlTree->identity->script->getAttribute('type');
360
+            }
361
+            if(isset($ldmlTree->identity->variant)) {
362
+                $data['locale']['variant'] = $ldmlTree->identity->variant->getAttribute('type');
363
+            }
364
+        }
365
+
366
+        if(isset($ldmlTree->localeDisplayNames)) {
367
+            $ldn = $ldmlTree->localeDisplayNames;
368
+
369
+            if(isset($ldn->languages)) {
370
+                $data['displayNames']['languages'] = isset($data['displayNames']['languages']) ? $data['displayNames']['languages'] : array();
371
+                $this->getTypeList($ldn->languages, $data['displayNames']['languages']);
372
+            }
373
+
374
+            if(isset($ldn->scripts)) {
375
+                $data['displayNames']['scripts'] = isset($data['displayNames']['scripts']) ? $data['displayNames']['scripts'] : array();
376
+                $this->getTypeList($ldn->scripts, $data['displayNames']['scripts']);
377
+            }
378
+
379
+            if(isset($ldn->territories)) {
380
+                $data['displayNames']['territories'] = isset($data['displayNames']['territories']) ? $data['displayNames']['territories'] : array();
381
+                $this->getTypeList($ldn->territories, $data['displayNames']['territories']);
382
+            }
383
+
384
+            if(isset($ldn->variants)) {
385
+                $data['displayNames']['variants'] = isset($data['displayNames']['variants']) ? $data['displayNames']['variants'] : array();
386
+                $this->getTypeList($ldn->variants, $data['displayNames']['variants']);
387
+            }
388
+
389
+            if(isset($ldn->keys)) {
390
+                $data['displayNames']['keys'] = isset($data['displayNames']['keys']) ? $data['displayNames']['keys'] : array();
391
+                $this->getTypeList($ldn->keys, $data['displayNames']['keys']);
392
+            }
393
+
394
+            /*
395 395
 			// not needed right now
396 396
 			if(isset($ldn->types)) {
397 397
 			}
398 398
 			*/
399 399
 
400
-			if(isset($ldn->measurementSystemNames)) {
401
-				$data['displayNames']['measurementSystemNames'] = isset($data['displayNames']['measurementSystemNames']) ? $data['displayNames']['measurementSystemNames'] : array();
402
-				$this->getTypeList($ldn->measurementSystemNames, $data['displayNames']['measurementSystemNames']);
403
-			}
404
-		}
405
-
406
-		if(isset($ldmlTree->layout->orientation)) {
407
-			$ori = $ldmlTree->layout->orientation;
408
-
409
-			$data['layout']['orientation']['lines'] = $ori->getAttribute('lines', $data['layout']['orientation']['lines']);
410
-			$data['layout']['orientation']['characters'] = $ori->getAttribute('characters', $data['layout']['orientation']['characters']);
411
-		}
412
-
413
-		if(isset($ldmlTree->delimiters)) {
414
-			$delims = $ldmlTree->delimiters;
415
-
416
-			if(isset($delims->quotationStart)) {
417
-				$data['delimiters']['quotationStart'] = $this->unescape($delims->quotationStart->getValue());
418
-			}
419
-			if(isset($delims->quotationEnd)) {
420
-				$data['delimiters']['quotationEnd'] = $this->unescape($delims->quotationEnd->getValue());
421
-			}
422
-			if(isset($delims->alternateQuotationStart)) {
423
-				$data['delimiters']['alternateQuotationStart'] = $this->unescape($delims->alternateQuotationStart->getValue());
424
-			}
425
-			if(isset($delims->alternateQuotationEnd)) {
426
-				$data['delimiters']['alternateQuotationEnd'] = $this->unescape($delims->alternateQuotationEnd->getValue());
427
-			}
428
-		}
429
-
430
-		if(isset($ldmlTree->dates)) {
431
-			$dates = $ldmlTree->dates;
432
-
433
-			if(isset($dates->calendars)) {
434
-				$cals = $dates->calendars;
435
-
436
-				foreach($cals as $calendar) {
437
-
438
-					if($calendar->getName() == 'default') {
439
-						$data['calendars']['default'] = $calendar->getAttribute('choice');
440
-					} elseif($calendar->getName() == 'calendar') {
441
-						$calendarName = $calendar->getAttribute('type');
442
-
443
-						if(!isset($data['calendars'][$calendarName])) {
444
-							$data['calendars'][$calendarName] = array();
445
-						}
446
-
447
-						if(isset($calendar->months)) {
448
-							$this->getCalendarWidth($calendar->months, 'month', $data['calendars'][$calendarName]);
449
-						}
450
-
451
-						if(isset($calendar->days)) {
452
-							$this->getCalendarWidth($calendar->days, 'day', $data['calendars'][$calendarName]);
453
-						}
454
-
455
-						if(isset($calendar->quarters)) {
456
-							$this->getCalendarWidth($calendar->quarters, 'quarter', $data['calendars'][$calendarName]);
457
-						}
458
-
459
-						if(isset($calendar->am)) {
460
-							$data['calendars'][$calendarName]['am'] = $this->unescape($calendar->am->getValue());
461
-						}
462
-						if(isset($calendar->pm)) {
463
-							$data['calendars'][$calendarName]['pm'] = $this->unescape($calendar->pm->getValue());
464
-						}
465
-
466
-						if(isset($calendar->eras)) {
467
-							if(isset($calendar->eras->eraNames)) {
468
-								foreach($this->getChildsOrAlias($calendar->eras->eraNames) as $era) {
469
-									$data['calendars'][$calendarName]['eras']['wide'][$era->getAttribute('type')] = $this->unescape($era->getValue());
470
-								}
471
-							}
472
-							if(isset($calendar->eras->eraAbbr)) {
473
-								foreach($this->getChildsOrAlias($calendar->eras->eraAbbr) as $era) {
474
-									$data['calendars'][$calendarName]['eras']['abbreviated'][$era->getAttribute('type')] = $this->unescape($era->getValue());
475
-								}
476
-							}
477
-							if(isset($calendar->eras->eraNarrow)) {
478
-								foreach($this->getChildsOrAlias($calendar->eras->eraNarrow) as $era) {
479
-									$data['calendars'][$calendarName]['eras']['narrow'][$era->getAttribute('type')] = $this->unescape($era->getValue());
480
-								}
481
-							}
482
-						}
483
-
484
-						if(isset($calendar->dateFormats)) {
485
-							$this->getDateOrTimeFormats($calendar->dateFormats, 'dateFormat', $data['calendars'][$calendarName]);
486
-						}
487
-						if(isset($calendar->timeFormats)) {
488
-							$this->getDateOrTimeFormats($calendar->timeFormats, 'timeFormat', $data['calendars'][$calendarName]);
489
-						}
490
-
491
-						if(isset($calendar->dateTimeFormats)) {
492
-							$dtf = $calendar->dateTimeFormats;
493
-							$data['calendars'][$calendarName]['dateTimeFormats']['default'] = isset($dtf->default) ? $dtf->default->getAttribute('choice') : '__default';
494
-
495
-							$dtfItems = $this->getChildsOrAlias($dtf);
496
-							foreach($dtfItems as $item) {
497
-								if($item->getName() == 'dateTimeFormatLength') {
498
-									if(isset($item->dateTimeFormat->pattern)) {
499
-										$data['calendars'][$calendarName]['dateTimeFormats']['formats'][$item->getAttribute('type', '__default')] = $this->unescape($item->dateTimeFormat->pattern->getValue(), true);
500
-									} else {
501
-										throw new AgaviException('unknown child content in dateTimeFormatLength tag');
502
-									}
503
-								} elseif($item->getName() == 'availableFormats') {
504
-									foreach($item as $dateFormatItem) {
505
-										if($dateFormatItem->getName() != 'dateFormatItem') {
506
-											throw new AgaviException('unknown childtag "' . $dateFormatItem->getName() . '" in availableFormats tag');
507
-										}
508
-										$data['calendars'][$calendarName]['dateTimeFormats']['availableFormats'][$dateFormatItem->getAttribute('id')] = $this->unescape($dateFormatItem->getValue(), true);
509
-									}
510
-								} elseif($item->getName() == 'appendItems') {
511
-									foreach($item as $appendItem) {
512
-										if($appendItem->getName() != 'appendItem') {
513
-											throw new AgaviException('unknown childtag "' . $appendItem->getName() . '" in appendItems tag');
514
-										}
515
-										$data['calendars'][$calendarName]['dateTimeFormats']['appendItems'][$appendItem->getAttribute('request')] = $this->unescape($appendItem->getValue(), true);
516
-									}
517
-								} elseif($item->getName() != 'default') {
518
-									throw new AgaviException('unknown childtag "' . $item->getName() . '" in dateTimeFormats tag');
519
-								}
520
-							}
521
-						}
522
-
523
-						if(isset($calendar->fields)) {
524
-							foreach($this->getChildsOrAlias($calendar->fields) as $field) {
525
-								$type = $field->getAttribute('type');
526
-								if(isset($field->displayName)) {
527
-									$data['calendars'][$calendarName]['fields'][$type]['displayName'] = $this->unescape($field->displayName->getValue());
528
-								}
529
-								if(isset($field->relative)) {
530
-									foreach($field as $relative) {
531
-										if($relative->getName() == 'relative') {
532
-											$data['calendars'][$calendarName]['fields'][$type]['relatives'][$relative->getAttribute('type')] = $this->unescape($relative->getValue());
533
-										}
534
-									}
535
-								}
536
-							}
537
-						}
538
-					} else {
539
-						throw new AgaviException('unknown childtag "' . $calendar->getName() . '" in calendars tag');
540
-					}
541
-				}
542
-			}
400
+            if(isset($ldn->measurementSystemNames)) {
401
+                $data['displayNames']['measurementSystemNames'] = isset($data['displayNames']['measurementSystemNames']) ? $data['displayNames']['measurementSystemNames'] : array();
402
+                $this->getTypeList($ldn->measurementSystemNames, $data['displayNames']['measurementSystemNames']);
403
+            }
404
+        }
405
+
406
+        if(isset($ldmlTree->layout->orientation)) {
407
+            $ori = $ldmlTree->layout->orientation;
408
+
409
+            $data['layout']['orientation']['lines'] = $ori->getAttribute('lines', $data['layout']['orientation']['lines']);
410
+            $data['layout']['orientation']['characters'] = $ori->getAttribute('characters', $data['layout']['orientation']['characters']);
411
+        }
412
+
413
+        if(isset($ldmlTree->delimiters)) {
414
+            $delims = $ldmlTree->delimiters;
415
+
416
+            if(isset($delims->quotationStart)) {
417
+                $data['delimiters']['quotationStart'] = $this->unescape($delims->quotationStart->getValue());
418
+            }
419
+            if(isset($delims->quotationEnd)) {
420
+                $data['delimiters']['quotationEnd'] = $this->unescape($delims->quotationEnd->getValue());
421
+            }
422
+            if(isset($delims->alternateQuotationStart)) {
423
+                $data['delimiters']['alternateQuotationStart'] = $this->unescape($delims->alternateQuotationStart->getValue());
424
+            }
425
+            if(isset($delims->alternateQuotationEnd)) {
426
+                $data['delimiters']['alternateQuotationEnd'] = $this->unescape($delims->alternateQuotationEnd->getValue());
427
+            }
428
+        }
429
+
430
+        if(isset($ldmlTree->dates)) {
431
+            $dates = $ldmlTree->dates;
432
+
433
+            if(isset($dates->calendars)) {
434
+                $cals = $dates->calendars;
435
+
436
+                foreach($cals as $calendar) {
437
+
438
+                    if($calendar->getName() == 'default') {
439
+                        $data['calendars']['default'] = $calendar->getAttribute('choice');
440
+                    } elseif($calendar->getName() == 'calendar') {
441
+                        $calendarName = $calendar->getAttribute('type');
442
+
443
+                        if(!isset($data['calendars'][$calendarName])) {
444
+                            $data['calendars'][$calendarName] = array();
445
+                        }
446
+
447
+                        if(isset($calendar->months)) {
448
+                            $this->getCalendarWidth($calendar->months, 'month', $data['calendars'][$calendarName]);
449
+                        }
450
+
451
+                        if(isset($calendar->days)) {
452
+                            $this->getCalendarWidth($calendar->days, 'day', $data['calendars'][$calendarName]);
453
+                        }
454
+
455
+                        if(isset($calendar->quarters)) {
456
+                            $this->getCalendarWidth($calendar->quarters, 'quarter', $data['calendars'][$calendarName]);
457
+                        }
458
+
459
+                        if(isset($calendar->am)) {
460
+                            $data['calendars'][$calendarName]['am'] = $this->unescape($calendar->am->getValue());
461
+                        }
462
+                        if(isset($calendar->pm)) {
463
+                            $data['calendars'][$calendarName]['pm'] = $this->unescape($calendar->pm->getValue());
464
+                        }
465
+
466
+                        if(isset($calendar->eras)) {
467
+                            if(isset($calendar->eras->eraNames)) {
468
+                                foreach($this->getChildsOrAlias($calendar->eras->eraNames) as $era) {
469
+                                    $data['calendars'][$calendarName]['eras']['wide'][$era->getAttribute('type')] = $this->unescape($era->getValue());
470
+                                }
471
+                            }
472
+                            if(isset($calendar->eras->eraAbbr)) {
473
+                                foreach($this->getChildsOrAlias($calendar->eras->eraAbbr) as $era) {
474
+                                    $data['calendars'][$calendarName]['eras']['abbreviated'][$era->getAttribute('type')] = $this->unescape($era->getValue());
475
+                                }
476
+                            }
477
+                            if(isset($calendar->eras->eraNarrow)) {
478
+                                foreach($this->getChildsOrAlias($calendar->eras->eraNarrow) as $era) {
479
+                                    $data['calendars'][$calendarName]['eras']['narrow'][$era->getAttribute('type')] = $this->unescape($era->getValue());
480
+                                }
481
+                            }
482
+                        }
483
+
484
+                        if(isset($calendar->dateFormats)) {
485
+                            $this->getDateOrTimeFormats($calendar->dateFormats, 'dateFormat', $data['calendars'][$calendarName]);
486
+                        }
487
+                        if(isset($calendar->timeFormats)) {
488
+                            $this->getDateOrTimeFormats($calendar->timeFormats, 'timeFormat', $data['calendars'][$calendarName]);
489
+                        }
490
+
491
+                        if(isset($calendar->dateTimeFormats)) {
492
+                            $dtf = $calendar->dateTimeFormats;
493
+                            $data['calendars'][$calendarName]['dateTimeFormats']['default'] = isset($dtf->default) ? $dtf->default->getAttribute('choice') : '__default';
494
+
495
+                            $dtfItems = $this->getChildsOrAlias($dtf);
496
+                            foreach($dtfItems as $item) {
497
+                                if($item->getName() == 'dateTimeFormatLength') {
498
+                                    if(isset($item->dateTimeFormat->pattern)) {
499
+                                        $data['calendars'][$calendarName]['dateTimeFormats']['formats'][$item->getAttribute('type', '__default')] = $this->unescape($item->dateTimeFormat->pattern->getValue(), true);
500
+                                    } else {
501
+                                        throw new AgaviException('unknown child content in dateTimeFormatLength tag');
502
+                                    }
503
+                                } elseif($item->getName() == 'availableFormats') {
504
+                                    foreach($item as $dateFormatItem) {
505
+                                        if($dateFormatItem->getName() != 'dateFormatItem') {
506
+                                            throw new AgaviException('unknown childtag "' . $dateFormatItem->getName() . '" in availableFormats tag');
507
+                                        }
508
+                                        $data['calendars'][$calendarName]['dateTimeFormats']['availableFormats'][$dateFormatItem->getAttribute('id')] = $this->unescape($dateFormatItem->getValue(), true);
509
+                                    }
510
+                                } elseif($item->getName() == 'appendItems') {
511
+                                    foreach($item as $appendItem) {
512
+                                        if($appendItem->getName() != 'appendItem') {
513
+                                            throw new AgaviException('unknown childtag "' . $appendItem->getName() . '" in appendItems tag');
514
+                                        }
515
+                                        $data['calendars'][$calendarName]['dateTimeFormats']['appendItems'][$appendItem->getAttribute('request')] = $this->unescape($appendItem->getValue(), true);
516
+                                    }
517
+                                } elseif($item->getName() != 'default') {
518
+                                    throw new AgaviException('unknown childtag "' . $item->getName() . '" in dateTimeFormats tag');
519
+                                }
520
+                            }
521
+                        }
522
+
523
+                        if(isset($calendar->fields)) {
524
+                            foreach($this->getChildsOrAlias($calendar->fields) as $field) {
525
+                                $type = $field->getAttribute('type');
526
+                                if(isset($field->displayName)) {
527
+                                    $data['calendars'][$calendarName]['fields'][$type]['displayName'] = $this->unescape($field->displayName->getValue());
528
+                                }
529
+                                if(isset($field->relative)) {
530
+                                    foreach($field as $relative) {
531
+                                        if($relative->getName() == 'relative') {
532
+                                            $data['calendars'][$calendarName]['fields'][$type]['relatives'][$relative->getAttribute('type')] = $this->unescape($relative->getValue());
533
+                                        }
534
+                                    }
535
+                                }
536
+                            }
537
+                        }
538
+                    } else {
539
+                        throw new AgaviException('unknown childtag "' . $calendar->getName() . '" in calendars tag');
540
+                    }
541
+                }
542
+            }
543 543
 			
544
-			if(isset($dates->timeZoneNames)) {
545
-				$tzn = $dates->timeZoneNames;
546
-				if(isset($tzn->hourFormat)) {
547
-					$data['timeZoneNames']['hourFormat'] = $this->unescape($tzn->hourFormat->getValue());
548
-				}
549
-				if(isset($tzn->hoursFormat)) {
550
-					$data['timeZoneNames']['hoursFormat'] = $this->unescape($tzn->hoursFormat->getValue());
551
-				}
552
-				if(isset($tzn->gmtFormat)) {
553
-					$data['timeZoneNames']['gmtFormat'] = $this->unescape($tzn->gmtFormat->getValue());
554
-				}
555
-				if(isset($tzn->regionFormat)) {
556
-					$data['timeZoneNames']['regionFormat'] = $this->unescape($tzn->regionFormat->getValue());
557
-				}
558
-				if(isset($tzn->fallbackFormat)) {
559
-					$data['timeZoneNames']['fallbackFormat'] = $this->unescape($tzn->fallbackFormat->getValue());
560
-				}
561
-				if(isset($tzn->abbreviationFallback)) {
562
-					$data['timeZoneNames']['abbreviationFallback'] = $tzn->abbreviationFallback->getAttribute('choice');
563
-				}
564
-				if(isset($tzn->singleCountries)) {
565
-					$data['timeZoneNames']['singleCountries'] = explode(' ', $tzn->singleCountries->getAttribute('list'));
566
-				}
567
-
568
-				foreach($tzn as $zone) {
569
-					$zoneName = $zone->getAttribute('type');
570
-					if($zone->getName() == 'zone') {
571
-						if(isset($zone->long->generic)) {
572
-							$data['timeZoneNames']['zones'][$zoneName]['long']['generic'] = $this->unescape($zone->long->generic->getValue());
573
-						}
574
-						if(isset($zone->long->standard)) {
575
-							$data['timeZoneNames']['zones'][$zoneName]['long']['standard'] = $this->unescape($zone->long->standard->getValue());
576
-						}
577
-						if(isset($zone->long->daylight)) {
578
-							$data['timeZoneNames']['zones'][$zoneName]['long']['daylight'] = $this->unescape($zone->long->daylight->getValue());
579
-						}
580
-						if(isset($zone->short->generic)) {
581
-							$data['timeZoneNames']['zones'][$zoneName]['short']['generic'] = $this->unescape($zone->short->generic->getValue());
582
-						}
583
-						if(isset($zone->short->standard)) {
584
-							$data['timeZoneNames']['zones'][$zoneName]['short']['standard'] = $this->unescape($zone->short->standard->getValue());
585
-						}
586
-						if(isset($zone->short->daylight)) {
587
-							$data['timeZoneNames']['zones'][$zoneName]['short']['daylight'] = $this->unescape($zone->short->daylight->getValue());
588
-						}
589
-						if(isset($zone->exemplarCity)) {
590
-							$data['timeZoneNames']['zones'][$zoneName]['exemplarCity'] = $this->unescape($zone->exemplarCity->getValue());
591
-						}
592
-
593
-					}
594
-				}
595
-			}
596
-		}
597
-
598
-		if(isset($ldmlTree->numbers)) {
599
-			$nums = $ldmlTree->numbers;
600
-			if(!isset($data['numbers'])) {
601
-				$data['numbers'] = array();
602
-			}
603
-
604
-			if(isset($nums->symbols)) {
605
-				$syms = $nums->symbols;
606
-				if(isset($syms->decimal)) {
607
-					$data['numbers']['symbols']['decimal'] = $this->unescape($syms->decimal->getValue());
608
-				}
609
-				if(isset($syms->group)) {
610
-					$data['numbers']['symbols']['group'] = $this->unescape($syms->group->getValue());
611
-				}
612
-				if(isset($syms->list)) {
613
-					$data['numbers']['symbols']['list'] = $this->unescape($syms->list->getValue());
614
-				}
615
-				if(isset($syms->percentSign)) {
616
-					$data['numbers']['symbols']['percentSign'] = $this->unescape($syms->percentSign->getValue());
617
-				}
618
-				if(isset($syms->nativeZeroDigit)) {
619
-					$data['numbers']['symbols']['nativeZeroDigit'] = $this->unescape($syms->nativeZeroDigit->getValue());
620
-				}
621
-				if(isset($syms->patternDigit)) {
622
-					$data['numbers']['symbols']['patternDigit'] = $this->unescape($syms->patternDigit->getValue());
623
-				}
624
-				if(isset($syms->plusSign)) {
625
-					$data['numbers']['symbols']['plusSign'] = $this->unescape($syms->plusSign->getValue());
626
-				}
627
-				if(isset($syms->minusSign)) {
628
-					$data['numbers']['symbols']['minusSign'] = $this->unescape($syms->minusSign->getValue());
629
-				}
630
-				if(isset($syms->exponential)) {
631
-					$data['numbers']['symbols']['exponential'] = $this->unescape($syms->exponential->getValue());
632
-				}
633
-				if(isset($syms->perMille)) {
634
-					$data['numbers']['symbols']['perMille'] = $this->unescape($syms->perMille->getValue());
635
-				}
636
-				if(isset($syms->infinity)) {
637
-					$data['numbers']['symbols']['infinity'] = $this->unescape($syms->infinity->getValue());
638
-				}
639
-				if(isset($syms->nan)) {
640
-					$data['numbers']['symbols']['nan'] = $this->unescape($syms->nan->getValue());
641
-				}
642
-			}
643
-			if(isset($nums->decimalFormats)) {
644
-				$this->getNumberFormats($nums->decimalFormats, 'decimalFormat', $data['numbers']);
645
-			}
646
-			if(isset($nums->scientificFormats)) {
647
-				$this->getNumberFormats($nums->scientificFormats, 'scientificFormat', $data['numbers']);
648
-			}
649
-			if(isset($nums->percentFormats)) {
650
-				$this->getNumberFormats($nums->percentFormats, 'percentFormat', $data['numbers']);
651
-			}
652
-			if(isset($nums->currencyFormats)) {
653
-				$cf = $nums->currencyFormats;
654
-
655
-				foreach($this->getChildsOrAlias($cf) as $itemLength) {
656
-					if($itemLength->getName() == 'default') {
657
-						$data['numbers']['currencyFormats']['default'] = $itemLength->getAttribute('choice');
658
-					} elseif($itemLength->getName() == 'currencyFormatLength') {
659
-						$itemLengthName = $itemLength->getAttribute('type', '__default');
660
-
661
-						foreach($this->getChildsOrAlias($itemLength) as $itemFormat) {
662
-							if($itemFormat->getName() == 'currencyFormat') {
663
-								if(isset($itemFormat->pattern)) {
664
-									$data['numbers']['currencyFormats'][$itemLengthName] = $this->unescape($itemFormat->pattern->getValue());
665
-								}
666
-							} else {
667
-								throw new AgaviException('unknown childtag "' . $itemFormat->getName() . '" in currencyFormatLength tag');
668
-							}
669
-
670
-						}
671
-					} elseif($itemLength->getName() == 'currencySpacing') {
672
-
673
-						if(isset($itemLength->beforeCurrency->currencyMatch)) {
674
-							$data['numbers']['currencySpacing']['beforeCurrency']['currencyMatch'] = $this->unescape($itemLength->beforeCurrency->currencyMatch->getValue());
675
-						}
676
-						if(isset($itemLength->beforeCurrency->surroundingMatch)) {
677
-							$data['numbers']['currencySpacing']['beforeCurrency']['surroundingMatch'] = $this->unescape($itemLength->beforeCurrency->surroundingMatch->getValue());
678
-						}
679
-						if(isset($itemLength->beforeCurrency->insertBetween)) {
680
-							$data['numbers']['currencySpacing']['beforeCurrency']['insertBetween'] = $this->unescape($itemLength->beforeCurrency->insertBetween->getValue());
681
-						}
682
-						if(isset($itemLength->afterCurrency->currencyMatch)) {
683
-							$data['numbers']['currencySpacing']['afterCurrency']['currencyMatch'] = $this->unescape($itemLength->afterCurrency->currencyMatch->getValue());
684
-						}
685
-						if(isset($itemLength->afterCurrency->surroundingMatch)) {
686
-							$data['numbers']['currencySpacing']['afterCurrency']['surroundingMatch'] = $this->unescape($itemLength->afterCurrency->surroundingMatch->getValue());
687
-						}
688
-						if(isset($itemLength->afterCurrency->insertBetween)) {
689
-							$data['numbers']['currencySpacing']['afterCurrency']['insertBetween'] = $this->unescape($itemLength->afterCurrency->insertBetween->getValue());
690
-						}
691
-
692
-					} else {
693
-						throw new AgaviException('unknown childtag "' . $itemLength->getName() . '" in currencyFormats tag');
694
-					}
695
-				}
696
-			}
697
-			if(isset($nums->currencies)) {
698
-				foreach($nums->currencies as $currency) {
699
-					$name = $currency->getAttribute('type');
700
-					if(isset($currency->displayName)) {
701
-						$data['numbers']['currencies'][$name]['displayName'] = $this->unescape($currency->displayName->getValue());
702
-					}
703
-					if(isset($currency->symbol)) {
704
-						$symbolValue = $this->unescape($currency->symbol->getValue());
705
-						if($currency->symbol->getAttribute('choice') == 'true') {
706
-							$symbolValue = explode('|', $symbolValue);
707
-						}
708
-						$data['numbers']['currencies'][$name]['symbol'] = $symbolValue;
709
-					}
710
-				}
711
-			}
712
-		}
713
-
714
-		return $data;
715
-	}
716
-
717
-	/**
718
-	 * Gets the value of each node with a type attribute.
719
-	 *
720
-	 * @param      array $list List of ConfigValueHolder items.
721
-	 * @param      array $data The array to store the parsed data to.
722
-	 *
723
-	 * @return     array The array with the data.
724
-	 *
725
-	 * @author     Dominik del Bondio <[email protected]>
726
-	 * @since      0.11.0
727
-	 */
728
-	protected function getTypeList($list, &$data)
729
-	{
730
-		// debug stuff to check if we missed any tags (lc = loop count)
731
-		$lc = 0;
732
-		foreach($list as $listItem) {
733
-			$type = $listItem->getAttribute('type');
734
-
735
-			if(!$listItem->hasAttribute('alt')) {
736
-				$data[$type] = $this->unescape($listItem->getValue());
737
-			}
738
-
739
-			++$lc;
740
-		}
741
-
742
-		if($lc != count($list->getChildren())) {
743
-			throw new AgaviException('wrong tagcount');
744
-		}
745
-
746
-		return $data;
747
-	}
748
-
749
-	/**
750
-	 * Gets the calendar widths for the given item.
751
-	 *
752
-	 * @param      ConfigValueHolder $item The item.
753
-	 * @param      string $name The name of item.
754
-	 * @param      array $data The array to store the parsed data to.
755
-	 *
756
-	 * @return     array The array with the data.
757
-	 *
758
-	 * @author     Dominik del Bondio <[email protected]>
759
-	 * @since      0.11.0
760
-	 */
761
-	protected function getCalendarWidth(ConfigValueHolder $item, $name, &$data)
762
-	{
763
-		$dataIdxName = $name . 's';
764
-
765
-		$items = $this->getChildsOrAlias($item);
766
-		foreach($items as $itemContext) {
767
-			if($itemContext->getName() == 'default') {
768
-				$data[$dataIdxName]['default'] = $itemContext->getAttribute('choice');
769
-			} elseif($itemContext->getName() == $name . 'Context') {
770
-				$itemContextName = $itemContext->getAttribute('type');
771
-
772
-				foreach($itemContext as $itemWidths) {
773
-					if($itemWidths->getName() == 'default') {
774
-						$data[$dataIdxName][$itemContextName]['default'] = $itemWidths->getAttribute('choice');
775
-					} elseif($itemWidths->getName() == $name . 'Width') {
776
-						$itemWidthName = $itemWidths->getAttribute('type');
777
-
778
-						$widthChildItems = $this->getChildsOrAlias($itemWidths);
779
-						foreach($widthChildItems as $item) {
780
-							if($item->getName() != $name) {
781
-								throw new AgaviException('unknown childtag "' . $item->getName() . '" in ' . $name . 'Widths tag');
782
-							}
783
-
784
-							if(!$item->hasAttribute('alt')) {
785
-								$itemName = $item->getAttribute('type');
786
-								$data[$dataIdxName][$itemContextName][$itemWidthName][$itemName] = $this->unescape($item->getValue());
787
-							}
788
-						}
789
-					} else {
790
-						throw new AgaviException('unknown childtag "' . $itemWidths->getName() . '" in ' . $name . 'Context tag');
791
-					}
792
-
793
-				}
794
-			} else {
795
-				throw new AgaviException('unknown childtag "' . $itemContext->getName() . '" in ' . $name . 's tag');
796
-			}
797
-		}
798
-	}
799
-
800
-	/**
801
-	 * Gets the date or time formats the given item.
802
-	 *
803
-	 * @param      ConfigValueHolder $item The item.
804
-	 * @param      string $name The name of item.
805
-	 * @param      array $data The array to store the parsed data to.
806
-	 *
807
-	 * @return     array The array with the data.
808
-	 *
809
-	 * @author     Dominik del Bondio <[email protected]>
810
-	 * @since      0.11.0
811
-	 */
812
-	protected function getDateOrTimeFormats(ConfigValueHolder $item, $name, &$data)
813
-	{
814
-		$dataIdxName = $name . 's';
815
-
816
-		$items = $this->getChildsOrAlias($item);
817
-		foreach($items as $itemLength) {
818
-			if($itemLength->getName() == 'default') {
819
-				$data[$dataIdxName]['default'] = $itemLength->getAttribute('choice');
820
-			} elseif($itemLength->getName() == $name . 'Length') {
821
-				$itemLengthName = $itemLength->getAttribute('type', '__default');
822
-
823
-				$aliasedItemLength = $this->getChildsOrAlias($itemLength);
824
-				foreach($aliasedItemLength as $itemFormat) {
825
-					if($itemFormat->getName() == $name) {
826
-						if(isset($itemFormat->pattern)) {
827
-							$data[$dataIdxName][$itemLengthName]['pattern'] = $this->unescape($itemFormat->pattern->getValue(), true);
828
-						}
829
-						if(isset($itemFormat->displayName)) {
830
-							$data[$dataIdxName][$itemLengthName]['displayName'] = $this->unescape($itemFormat->displayName->getValue());
831
-						}
832
-					} else {
833
-						throw new AgaviException('unknown childtag "' . $itemFormat->getName() . '" in ' . $name . 'Length tag');
834
-					}
835
-
836
-				}
837
-			} else {
838
-				throw new AgaviException('unknown childtag "' . $itemLength->getName() . '" in ' . $name . 's tag');
839
-			}
840
-		}
841
-	}
842
-
843
-	/**
844
-	 * Gets the number formats the given item.
845
-	 *
846
-	 * @param      ConfigValueHolder The item.
847
-	 * @param      string The name of item.
848
-	 * @param      array The array to store the parsed data to.
849
-	 *
850
-	 * @return     array The array with the data.
851
-	 *
852
-	 * @author     Dominik del Bondio <[email protected]>
853
-	 * @since      0.11.0
854
-	 */
855
-	protected function getNumberFormats($item, $name, &$data)
856
-	{
857
-		$dataIdxName = $name . 's';
858
-
859
-		$items = $this->getChildsOrAlias($item);
860
-		foreach($items as $itemLength) {
861
-			if($itemLength->getName() == 'default') {
862
-				$data[$dataIdxName]['default'] = $itemLength->getAttribute('choice');
863
-			} elseif($itemLength->getName() == $name . 'Length') {
864
-				$itemLengthName = $itemLength->getAttribute('type', '__default');
865
-
866
-				foreach($this->getChildsOrAlias($itemLength) as $itemFormat) {
867
-					if($itemFormat->getName() == $name) {
868
-						if(isset($itemFormat->pattern)) {
869
-							$data[$dataIdxName][$itemLengthName] = $this->unescape($itemFormat->pattern->getValue());
870
-						}
871
-					} else {
872
-						throw new AgaviException('unknown childtag "' . $itemFormat->getName() . '" in ' . $name . 'Length tag');
873
-					}
874
-
875
-				}
876
-			} else {
877
-				throw new AgaviException('unknown childtag "' . $itemLength->getName() . '" in ' . $name . 's tag');
878
-			}
879
-		}
880
-	}
881
-
882
-	/**
883
-	 * Resolves the alias LDML tag.
884
-	 *
885
-	 * @param      ConfigValueHolder $item The item.
886
-	 *
887
-	 * @return     mixed Either the item if there is no alias or the resolved 
888
-	 *                   alias.
889
-	 *
890
-	 * @author     Dominik del Bondio <[email protected]>
891
-	 * @since      0.11.0
892
-	 */
893
-	protected function getChildsOrAlias(ConfigValueHolder $item)
894
-	{
895
-		if(isset($item->alias)) {
896
-			$alias = $item->alias;
897
-			if($alias->getAttribute('source') != 'locale') {
898
-				throw new AgaviException('The alias handling doesn\'t support any source except locale (' . $alias->getAttribute('source') . ' was given)');
899
-			}
900
-
901
-			$pathParts = explode('/', $alias->getAttribute('path'));
902
-
903
-			$currentNodeId = $item->getAttribute('__agavi_node_id');
544
+            if(isset($dates->timeZoneNames)) {
545
+                $tzn = $dates->timeZoneNames;
546
+                if(isset($tzn->hourFormat)) {
547
+                    $data['timeZoneNames']['hourFormat'] = $this->unescape($tzn->hourFormat->getValue());
548
+                }
549
+                if(isset($tzn->hoursFormat)) {
550
+                    $data['timeZoneNames']['hoursFormat'] = $this->unescape($tzn->hoursFormat->getValue());
551
+                }
552
+                if(isset($tzn->gmtFormat)) {
553
+                    $data['timeZoneNames']['gmtFormat'] = $this->unescape($tzn->gmtFormat->getValue());
554
+                }
555
+                if(isset($tzn->regionFormat)) {
556
+                    $data['timeZoneNames']['regionFormat'] = $this->unescape($tzn->regionFormat->getValue());
557
+                }
558
+                if(isset($tzn->fallbackFormat)) {
559
+                    $data['timeZoneNames']['fallbackFormat'] = $this->unescape($tzn->fallbackFormat->getValue());
560
+                }
561
+                if(isset($tzn->abbreviationFallback)) {
562
+                    $data['timeZoneNames']['abbreviationFallback'] = $tzn->abbreviationFallback->getAttribute('choice');
563
+                }
564
+                if(isset($tzn->singleCountries)) {
565
+                    $data['timeZoneNames']['singleCountries'] = explode(' ', $tzn->singleCountries->getAttribute('list'));
566
+                }
567
+
568
+                foreach($tzn as $zone) {
569
+                    $zoneName = $zone->getAttribute('type');
570
+                    if($zone->getName() == 'zone') {
571
+                        if(isset($zone->long->generic)) {
572
+                            $data['timeZoneNames']['zones'][$zoneName]['long']['generic'] = $this->unescape($zone->long->generic->getValue());
573
+                        }
574
+                        if(isset($zone->long->standard)) {
575
+                            $data['timeZoneNames']['zones'][$zoneName]['long']['standard'] = $this->unescape($zone->long->standard->getValue());
576
+                        }
577
+                        if(isset($zone->long->daylight)) {
578
+                            $data['timeZoneNames']['zones'][$zoneName]['long']['daylight'] = $this->unescape($zone->long->daylight->getValue());
579
+                        }
580
+                        if(isset($zone->short->generic)) {
581
+                            $data['timeZoneNames']['zones'][$zoneName]['short']['generic'] = $this->unescape($zone->short->generic->getValue());
582
+                        }
583
+                        if(isset($zone->short->standard)) {
584
+                            $data['timeZoneNames']['zones'][$zoneName]['short']['standard'] = $this->unescape($zone->short->standard->getValue());
585
+                        }
586
+                        if(isset($zone->short->daylight)) {
587
+                            $data['timeZoneNames']['zones'][$zoneName]['short']['daylight'] = $this->unescape($zone->short->daylight->getValue());
588
+                        }
589
+                        if(isset($zone->exemplarCity)) {
590
+                            $data['timeZoneNames']['zones'][$zoneName]['exemplarCity'] = $this->unescape($zone->exemplarCity->getValue());
591
+                        }
592
+
593
+                    }
594
+                }
595
+            }
596
+        }
597
+
598
+        if(isset($ldmlTree->numbers)) {
599
+            $nums = $ldmlTree->numbers;
600
+            if(!isset($data['numbers'])) {
601
+                $data['numbers'] = array();
602
+            }
603
+
604
+            if(isset($nums->symbols)) {
605
+                $syms = $nums->symbols;
606
+                if(isset($syms->decimal)) {
607
+                    $data['numbers']['symbols']['decimal'] = $this->unescape($syms->decimal->getValue());
608
+                }
609
+                if(isset($syms->group)) {
610
+                    $data['numbers']['symbols']['group'] = $this->unescape($syms->group->getValue());
611
+                }
612
+                if(isset($syms->list)) {
613
+                    $data['numbers']['symbols']['list'] = $this->unescape($syms->list->getValue());
614
+                }
615
+                if(isset($syms->percentSign)) {
616
+                    $data['numbers']['symbols']['percentSign'] = $this->unescape($syms->percentSign->getValue());
617
+                }
618
+                if(isset($syms->nativeZeroDigit)) {
619
+                    $data['numbers']['symbols']['nativeZeroDigit'] = $this->unescape($syms->nativeZeroDigit->getValue());
620
+                }
621
+                if(isset($syms->patternDigit)) {
622
+                    $data['numbers']['symbols']['patternDigit'] = $this->unescape($syms->patternDigit->getValue());
623
+                }
624
+                if(isset($syms->plusSign)) {
625
+                    $data['numbers']['symbols']['plusSign'] = $this->unescape($syms->plusSign->getValue());
626
+                }
627
+                if(isset($syms->minusSign)) {
628
+                    $data['numbers']['symbols']['minusSign'] = $this->unescape($syms->minusSign->getValue());
629
+                }
630
+                if(isset($syms->exponential)) {
631
+                    $data['numbers']['symbols']['exponential'] = $this->unescape($syms->exponential->getValue());
632
+                }
633
+                if(isset($syms->perMille)) {
634
+                    $data['numbers']['symbols']['perMille'] = $this->unescape($syms->perMille->getValue());
635
+                }
636
+                if(isset($syms->infinity)) {
637
+                    $data['numbers']['symbols']['infinity'] = $this->unescape($syms->infinity->getValue());
638
+                }
639
+                if(isset($syms->nan)) {
640
+                    $data['numbers']['symbols']['nan'] = $this->unescape($syms->nan->getValue());
641
+                }
642
+            }
643
+            if(isset($nums->decimalFormats)) {
644
+                $this->getNumberFormats($nums->decimalFormats, 'decimalFormat', $data['numbers']);
645
+            }
646
+            if(isset($nums->scientificFormats)) {
647
+                $this->getNumberFormats($nums->scientificFormats, 'scientificFormat', $data['numbers']);
648
+            }
649
+            if(isset($nums->percentFormats)) {
650
+                $this->getNumberFormats($nums->percentFormats, 'percentFormat', $data['numbers']);
651
+            }
652
+            if(isset($nums->currencyFormats)) {
653
+                $cf = $nums->currencyFormats;
654
+
655
+                foreach($this->getChildsOrAlias($cf) as $itemLength) {
656
+                    if($itemLength->getName() == 'default') {
657
+                        $data['numbers']['currencyFormats']['default'] = $itemLength->getAttribute('choice');
658
+                    } elseif($itemLength->getName() == 'currencyFormatLength') {
659
+                        $itemLengthName = $itemLength->getAttribute('type', '__default');
660
+
661
+                        foreach($this->getChildsOrAlias($itemLength) as $itemFormat) {
662
+                            if($itemFormat->getName() == 'currencyFormat') {
663
+                                if(isset($itemFormat->pattern)) {
664
+                                    $data['numbers']['currencyFormats'][$itemLengthName] = $this->unescape($itemFormat->pattern->getValue());
665
+                                }
666
+                            } else {
667
+                                throw new AgaviException('unknown childtag "' . $itemFormat->getName() . '" in currencyFormatLength tag');
668
+                            }
669
+
670
+                        }
671
+                    } elseif($itemLength->getName() == 'currencySpacing') {
672
+
673
+                        if(isset($itemLength->beforeCurrency->currencyMatch)) {
674
+                            $data['numbers']['currencySpacing']['beforeCurrency']['currencyMatch'] = $this->unescape($itemLength->beforeCurrency->currencyMatch->getValue());
675
+                        }
676
+                        if(isset($itemLength->beforeCurrency->surroundingMatch)) {
677
+                            $data['numbers']['currencySpacing']['beforeCurrency']['surroundingMatch'] = $this->unescape($itemLength->beforeCurrency->surroundingMatch->getValue());
678
+                        }
679
+                        if(isset($itemLength->beforeCurrency->insertBetween)) {
680
+                            $data['numbers']['currencySpacing']['beforeCurrency']['insertBetween'] = $this->unescape($itemLength->beforeCurrency->insertBetween->getValue());
681
+                        }
682
+                        if(isset($itemLength->afterCurrency->currencyMatch)) {
683
+                            $data['numbers']['currencySpacing']['afterCurrency']['currencyMatch'] = $this->unescape($itemLength->afterCurrency->currencyMatch->getValue());
684
+                        }
685
+                        if(isset($itemLength->afterCurrency->surroundingMatch)) {
686
+                            $data['numbers']['currencySpacing']['afterCurrency']['surroundingMatch'] = $this->unescape($itemLength->afterCurrency->surroundingMatch->getValue());
687
+                        }
688
+                        if(isset($itemLength->afterCurrency->insertBetween)) {
689
+                            $data['numbers']['currencySpacing']['afterCurrency']['insertBetween'] = $this->unescape($itemLength->afterCurrency->insertBetween->getValue());
690
+                        }
691
+
692
+                    } else {
693
+                        throw new AgaviException('unknown childtag "' . $itemLength->getName() . '" in currencyFormats tag');
694
+                    }
695
+                }
696
+            }
697
+            if(isset($nums->currencies)) {
698
+                foreach($nums->currencies as $currency) {
699
+                    $name = $currency->getAttribute('type');
700
+                    if(isset($currency->displayName)) {
701
+                        $data['numbers']['currencies'][$name]['displayName'] = $this->unescape($currency->displayName->getValue());
702
+                    }
703
+                    if(isset($currency->symbol)) {
704
+                        $symbolValue = $this->unescape($currency->symbol->getValue());
705
+                        if($currency->symbol->getAttribute('choice') == 'true') {
706
+                            $symbolValue = explode('|', $symbolValue);
707
+                        }
708
+                        $data['numbers']['currencies'][$name]['symbol'] = $symbolValue;
709
+                    }
710
+                }
711
+            }
712
+        }
713
+
714
+        return $data;
715
+    }
716
+
717
+    /**
718
+     * Gets the value of each node with a type attribute.
719
+     *
720
+     * @param      array $list List of ConfigValueHolder items.
721
+     * @param      array $data The array to store the parsed data to.
722
+     *
723
+     * @return     array The array with the data.
724
+     *
725
+     * @author     Dominik del Bondio <[email protected]>
726
+     * @since      0.11.0
727
+     */
728
+    protected function getTypeList($list, &$data)
729
+    {
730
+        // debug stuff to check if we missed any tags (lc = loop count)
731
+        $lc = 0;
732
+        foreach($list as $listItem) {
733
+            $type = $listItem->getAttribute('type');
734
+
735
+            if(!$listItem->hasAttribute('alt')) {
736
+                $data[$type] = $this->unescape($listItem->getValue());
737
+            }
738
+
739
+            ++$lc;
740
+        }
741
+
742
+        if($lc != count($list->getChildren())) {
743
+            throw new AgaviException('wrong tagcount');
744
+        }
745
+
746
+        return $data;
747
+    }
748
+
749
+    /**
750
+     * Gets the calendar widths for the given item.
751
+     *
752
+     * @param      ConfigValueHolder $item The item.
753
+     * @param      string $name The name of item.
754
+     * @param      array $data The array to store the parsed data to.
755
+     *
756
+     * @return     array The array with the data.
757
+     *
758
+     * @author     Dominik del Bondio <[email protected]>
759
+     * @since      0.11.0
760
+     */
761
+    protected function getCalendarWidth(ConfigValueHolder $item, $name, &$data)
762
+    {
763
+        $dataIdxName = $name . 's';
764
+
765
+        $items = $this->getChildsOrAlias($item);
766
+        foreach($items as $itemContext) {
767
+            if($itemContext->getName() == 'default') {
768
+                $data[$dataIdxName]['default'] = $itemContext->getAttribute('choice');
769
+            } elseif($itemContext->getName() == $name . 'Context') {
770
+                $itemContextName = $itemContext->getAttribute('type');
771
+
772
+                foreach($itemContext as $itemWidths) {
773
+                    if($itemWidths->getName() == 'default') {
774
+                        $data[$dataIdxName][$itemContextName]['default'] = $itemWidths->getAttribute('choice');
775
+                    } elseif($itemWidths->getName() == $name . 'Width') {
776
+                        $itemWidthName = $itemWidths->getAttribute('type');
777
+
778
+                        $widthChildItems = $this->getChildsOrAlias($itemWidths);
779
+                        foreach($widthChildItems as $item) {
780
+                            if($item->getName() != $name) {
781
+                                throw new AgaviException('unknown childtag "' . $item->getName() . '" in ' . $name . 'Widths tag');
782
+                            }
783
+
784
+                            if(!$item->hasAttribute('alt')) {
785
+                                $itemName = $item->getAttribute('type');
786
+                                $data[$dataIdxName][$itemContextName][$itemWidthName][$itemName] = $this->unescape($item->getValue());
787
+                            }
788
+                        }
789
+                    } else {
790
+                        throw new AgaviException('unknown childtag "' . $itemWidths->getName() . '" in ' . $name . 'Context tag');
791
+                    }
792
+
793
+                }
794
+            } else {
795
+                throw new AgaviException('unknown childtag "' . $itemContext->getName() . '" in ' . $name . 's tag');
796
+            }
797
+        }
798
+    }
799
+
800
+    /**
801
+     * Gets the date or time formats the given item.
802
+     *
803
+     * @param      ConfigValueHolder $item The item.
804
+     * @param      string $name The name of item.
805
+     * @param      array $data The array to store the parsed data to.
806
+     *
807
+     * @return     array The array with the data.
808
+     *
809
+     * @author     Dominik del Bondio <[email protected]>
810
+     * @since      0.11.0
811
+     */
812
+    protected function getDateOrTimeFormats(ConfigValueHolder $item, $name, &$data)
813
+    {
814
+        $dataIdxName = $name . 's';
815
+
816
+        $items = $this->getChildsOrAlias($item);
817
+        foreach($items as $itemLength) {
818
+            if($itemLength->getName() == 'default') {
819
+                $data[$dataIdxName]['default'] = $itemLength->getAttribute('choice');
820
+            } elseif($itemLength->getName() == $name . 'Length') {
821
+                $itemLengthName = $itemLength->getAttribute('type', '__default');
822
+
823
+                $aliasedItemLength = $this->getChildsOrAlias($itemLength);
824
+                foreach($aliasedItemLength as $itemFormat) {
825
+                    if($itemFormat->getName() == $name) {
826
+                        if(isset($itemFormat->pattern)) {
827
+                            $data[$dataIdxName][$itemLengthName]['pattern'] = $this->unescape($itemFormat->pattern->getValue(), true);
828
+                        }
829
+                        if(isset($itemFormat->displayName)) {
830
+                            $data[$dataIdxName][$itemLengthName]['displayName'] = $this->unescape($itemFormat->displayName->getValue());
831
+                        }
832
+                    } else {
833
+                        throw new AgaviException('unknown childtag "' . $itemFormat->getName() . '" in ' . $name . 'Length tag');
834
+                    }
835
+
836
+                }
837
+            } else {
838
+                throw new AgaviException('unknown childtag "' . $itemLength->getName() . '" in ' . $name . 's tag');
839
+            }
840
+        }
841
+    }
842
+
843
+    /**
844
+     * Gets the number formats the given item.
845
+     *
846
+     * @param      ConfigValueHolder The item.
847
+     * @param      string The name of item.
848
+     * @param      array The array to store the parsed data to.
849
+     *
850
+     * @return     array The array with the data.
851
+     *
852
+     * @author     Dominik del Bondio <[email protected]>
853
+     * @since      0.11.0
854
+     */
855
+    protected function getNumberFormats($item, $name, &$data)
856
+    {
857
+        $dataIdxName = $name . 's';
858
+
859
+        $items = $this->getChildsOrAlias($item);
860
+        foreach($items as $itemLength) {
861
+            if($itemLength->getName() == 'default') {
862
+                $data[$dataIdxName]['default'] = $itemLength->getAttribute('choice');
863
+            } elseif($itemLength->getName() == $name . 'Length') {
864
+                $itemLengthName = $itemLength->getAttribute('type', '__default');
865
+
866
+                foreach($this->getChildsOrAlias($itemLength) as $itemFormat) {
867
+                    if($itemFormat->getName() == $name) {
868
+                        if(isset($itemFormat->pattern)) {
869
+                            $data[$dataIdxName][$itemLengthName] = $this->unescape($itemFormat->pattern->getValue());
870
+                        }
871
+                    } else {
872
+                        throw new AgaviException('unknown childtag "' . $itemFormat->getName() . '" in ' . $name . 'Length tag');
873
+                    }
874
+
875
+                }
876
+            } else {
877
+                throw new AgaviException('unknown childtag "' . $itemLength->getName() . '" in ' . $name . 's tag');
878
+            }
879
+        }
880
+    }
881
+
882
+    /**
883
+     * Resolves the alias LDML tag.
884
+     *
885
+     * @param      ConfigValueHolder $item The item.
886
+     *
887
+     * @return     mixed Either the item if there is no alias or the resolved 
888
+     *                   alias.
889
+     *
890
+     * @author     Dominik del Bondio <[email protected]>
891
+     * @since      0.11.0
892
+     */
893
+    protected function getChildsOrAlias(ConfigValueHolder $item)
894
+    {
895
+        if(isset($item->alias)) {
896
+            $alias = $item->alias;
897
+            if($alias->getAttribute('source') != 'locale') {
898
+                throw new AgaviException('The alias handling doesn\'t support any source except locale (' . $alias->getAttribute('source') . ' was given)');
899
+            }
900
+
901
+            $pathParts = explode('/', $alias->getAttribute('path'));
902
+
903
+            $currentNodeId = $item->getAttribute('__agavi_node_id');
904 904
 			
905
-			foreach($pathParts as $part) {
906
-				// select the parent node
907
-				if($part == '..') {
908
-					$currentNodeId = $this->nodeRefs[$currentNodeId]->getAttribute('__agavi_parent_id');
909
-				} else {
910
-					$predicates = array();
911
-					if(preg_match('#([^\[]+)\[([^\]]+)\]#', $part, $match)) {
912
-						if(!preg_match('#@([^=]+)=\'([^\']+)\'#', $match[2], $predMatch)) {
913
-							throw new AgaviException('Unknown predicate ' . $match[2] . ' in alias xpath spec');
914
-						}
915
-						$tagName = $match[1];
916
-						$predicates[$predMatch[1]] = $predMatch[2];
917
-					} else {
918
-						$tagName = $part;
919
-					}
920
-					foreach($this->nodeRefs[$currentNodeId]->getChildren() as $childNode) {
921
-						$isSearchedNode = false;
922
-						if($childNode->getName() == $tagName) {
923
-							$predMatches = 0;
924
-							foreach($predicates as $attrib => $value) {
925
-								if($childNode->getAttribute($attrib) == $value) {
926
-									++$predMatches;
927
-								}
928
-							}
929
-							if($predMatches == count($predicates)) {
930
-								$isSearchedNode = true;
931
-							}
932
-						}
933
-
934
-						if($isSearchedNode) {
935
-							$currentNodeId = $childNode->getAttribute('__agavi_node_id');
936
-						}
937
-					}
938
-				}
939
-			}
940
-
941
-			return $this->nodeRefs[$currentNodeId]->getChildren();
942
-		} else {
943
-			return $item;
944
-		}
945
-	}
905
+            foreach($pathParts as $part) {
906
+                // select the parent node
907
+                if($part == '..') {
908
+                    $currentNodeId = $this->nodeRefs[$currentNodeId]->getAttribute('__agavi_parent_id');
909
+                } else {
910
+                    $predicates = array();
911
+                    if(preg_match('#([^\[]+)\[([^\]]+)\]#', $part, $match)) {
912
+                        if(!preg_match('#@([^=]+)=\'([^\']+)\'#', $match[2], $predMatch)) {
913
+                            throw new AgaviException('Unknown predicate ' . $match[2] . ' in alias xpath spec');
914
+                        }
915
+                        $tagName = $match[1];
916
+                        $predicates[$predMatch[1]] = $predMatch[2];
917
+                    } else {
918
+                        $tagName = $part;
919
+                    }
920
+                    foreach($this->nodeRefs[$currentNodeId]->getChildren() as $childNode) {
921
+                        $isSearchedNode = false;
922
+                        if($childNode->getName() == $tagName) {
923
+                            $predMatches = 0;
924
+                            foreach($predicates as $attrib => $value) {
925
+                                if($childNode->getAttribute($attrib) == $value) {
926
+                                    ++$predMatches;
927
+                                }
928
+                            }
929
+                            if($predMatches == count($predicates)) {
930
+                                $isSearchedNode = true;
931
+                            }
932
+                        }
933
+
934
+                        if($isSearchedNode) {
935
+                            $currentNodeId = $childNode->getAttribute('__agavi_node_id');
936
+                        }
937
+                    }
938
+                }
939
+            }
940
+
941
+            return $this->nodeRefs[$currentNodeId]->getChildren();
942
+        } else {
943
+            return $item;
944
+        }
945
+    }
946 946
 	
947
-	/**
948
-	 * Unescapes unicode escapes
949
-	 * 
950
-	 * @link       http://unicode.org/reports/tr35/#Unicode_Sets
951
-	 * 
952
-	 * @param      string $input The string to unescape.
953
-	 * @param      bool   $handleQuotes Whether the string needs to handle quoting behaviour
954
-	 *
955
-	 * @return     string The unescaped string.
956
-	 *
957
-	 * @author     Dominik del Bondio <[email protected]>
958
-	 * @since      0.11.0	
959
-	 */
960
-	protected function unescape($input, $handleQuotes = false)
961
-	{
962
-		$output = '';
963
-		$hex = '[0-9A-Fa-f]';
964
-		$rx = '\\\\(\\\\|u' . $hex . '{4}|U' . $hex . '{8}|x' . $hex .'{1,2}|[0-7]{1,3}|.)';
965
-		if($handleQuotes) {
966
-			// needs to be < -1 to not confuse the algorithm in the first run
967
-			$lastClose = -2;
968
-			if(preg_match_all("#'(?:''|[^'])+'|" . $rx . "#", $input, $matches, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE)) {
969
-				$output = $input;
970
-				$offsetMod = 0;
971
-				$ml = $matches[0];
972
-				$len = count($ml);
973
-				for($i = 0; $i < $len; ++ $i) {
974
-					$match = $ml[$i];
975
-					if($match[0][0] != '\'') {
976
-						// we check if there is a quoted string directly before or directly after the escape sequence
977
-						// by using the string lengths and the offset of the matches. Since an escape sequence directly before
978
-						// this sequence results in an quoted string we only check if its really a quoted string and not an
979
-						// escape sequence for parts coming after this sequence
980
-						$quoteBefore = ($i > 0 && (strlen($ml[$i - 1][0]) + $ml[$i - 1][1]) == $match[1]);
981
-						$quoteAfter = ($i + 1 < $len && $ml[$i + 1][0][0] == '\'' && (strlen($match[0]) + $match[1]) == $ml[$i + 1][1]);
982
-						$oldLen = strlen($output);
983
-						$unescaped = $this->unescapeCallback(array($match[0], substr($match[0], 1)));
984
-						$unescaped = ($quoteBefore ? '' : '\'') . $unescaped . ($quoteAfter ? '' : '\'');
985
-						$replacedPartLen = strlen($match[0]) + ((int) $quoteBefore) + ((int) $quoteAfter);
986
-						// replace the matched escape sequence with the unescaped one. we also replace the opening or closing quote
987
-						// from the quoted part before or after this escape sequence to include the unescaped string into the closed part
988
-						$output = substr_replace($output, $unescaped, $offsetMod + $match[1] + ($quoteBefore ? -1 : 0), $replacedPartLen);
989
-						// since the string length gets changed, we have to track the size change so we can adjust the offset from the match
990
-						$offsetMod += strlen($output) - $oldLen;
991
-					}
992
-				}
993
-			} else {
994
-				$output = $input;
995
-			}
996
-		} else {
997
-			$output = preg_replace_callback('#' . $rx . '#', array($this, 'unescapeCallback'), $input);
998
-		}
999
-
1000
-		return $output;
1001
-	}
947
+    /**
948
+     * Unescapes unicode escapes
949
+     * 
950
+     * @link       http://unicode.org/reports/tr35/#Unicode_Sets
951
+     * 
952
+     * @param      string $input The string to unescape.
953
+     * @param      bool   $handleQuotes Whether the string needs to handle quoting behaviour
954
+     *
955
+     * @return     string The unescaped string.
956
+     *
957
+     * @author     Dominik del Bondio <[email protected]>
958
+     * @since      0.11.0	
959
+     */
960
+    protected function unescape($input, $handleQuotes = false)
961
+    {
962
+        $output = '';
963
+        $hex = '[0-9A-Fa-f]';
964
+        $rx = '\\\\(\\\\|u' . $hex . '{4}|U' . $hex . '{8}|x' . $hex .'{1,2}|[0-7]{1,3}|.)';
965
+        if($handleQuotes) {
966
+            // needs to be < -1 to not confuse the algorithm in the first run
967
+            $lastClose = -2;
968
+            if(preg_match_all("#'(?:''|[^'])+'|" . $rx . "#", $input, $matches, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE)) {
969
+                $output = $input;
970
+                $offsetMod = 0;
971
+                $ml = $matches[0];
972
+                $len = count($ml);
973
+                for($i = 0; $i < $len; ++ $i) {
974
+                    $match = $ml[$i];
975
+                    if($match[0][0] != '\'') {
976
+                        // we check if there is a quoted string directly before or directly after the escape sequence
977
+                        // by using the string lengths and the offset of the matches. Since an escape sequence directly before
978
+                        // this sequence results in an quoted string we only check if its really a quoted string and not an
979
+                        // escape sequence for parts coming after this sequence
980
+                        $quoteBefore = ($i > 0 && (strlen($ml[$i - 1][0]) + $ml[$i - 1][1]) == $match[1]);
981
+                        $quoteAfter = ($i + 1 < $len && $ml[$i + 1][0][0] == '\'' && (strlen($match[0]) + $match[1]) == $ml[$i + 1][1]);
982
+                        $oldLen = strlen($output);
983
+                        $unescaped = $this->unescapeCallback(array($match[0], substr($match[0], 1)));
984
+                        $unescaped = ($quoteBefore ? '' : '\'') . $unescaped . ($quoteAfter ? '' : '\'');
985
+                        $replacedPartLen = strlen($match[0]) + ((int) $quoteBefore) + ((int) $quoteAfter);
986
+                        // replace the matched escape sequence with the unescaped one. we also replace the opening or closing quote
987
+                        // from the quoted part before or after this escape sequence to include the unescaped string into the closed part
988
+                        $output = substr_replace($output, $unescaped, $offsetMod + $match[1] + ($quoteBefore ? -1 : 0), $replacedPartLen);
989
+                        // since the string length gets changed, we have to track the size change so we can adjust the offset from the match
990
+                        $offsetMod += strlen($output) - $oldLen;
991
+                    }
992
+                }
993
+            } else {
994
+                $output = $input;
995
+            }
996
+        } else {
997
+            $output = preg_replace_callback('#' . $rx . '#', array($this, 'unescapeCallback'), $input);
998
+        }
999
+
1000
+        return $output;
1001
+    }
1002 1002
 	
1003
-	/**
1004
-	 * Unescapes a single unicode escape sequence. This is designed to be a 
1005
-	 * preg_replace_callback callback function.
1006
-	 * 
1007
-	 * @param      array $matches The match.
1008
-	 *
1009
-	 * @return     string The unescaped sequence.
1010
-	 *
1011
-	 * @author     Dominik del Bondio <[email protected]>
1012
-	 * @since      0.11.0	
1013
-	 */
1014
-	protected function unescapeCallback($matches)
1015
-	{
1016
-		static $map = array(
1017
-			'a' => "\x07",
1018
-			'b' => "\x08",
1019
-			't' => "\x09",
1020
-			'n' => "\x0A",
1021
-			'v' => "\x0B",
1022
-			'f' => "\x0C",
1023
-			'r' => "\x0D",
1024
-			'\\' => '\\',
1025
-		);
1003
+    /**
1004
+     * Unescapes a single unicode escape sequence. This is designed to be a 
1005
+     * preg_replace_callback callback function.
1006
+     * 
1007
+     * @param      array $matches The match.
1008
+     *
1009
+     * @return     string The unescaped sequence.
1010
+     *
1011
+     * @author     Dominik del Bondio <[email protected]>
1012
+     * @since      0.11.0	
1013
+     */
1014
+    protected function unescapeCallback($matches)
1015
+    {
1016
+        static $map = array(
1017
+            'a' => "\x07",
1018
+            'b' => "\x08",
1019
+            't' => "\x09",
1020
+            'n' => "\x0A",
1021
+            'v' => "\x0B",
1022
+            'f' => "\x0C",
1023
+            'r' => "\x0D",
1024
+            '\\' => '\\',
1025
+        );
1026 1026
 		
1027 1027
 		
1028
-		$res = '';
1028
+        $res = '';
1029 1029
 		
1030
-		$char = $matches[1][0];
1031
-		$seq = substr($matches[1], 1);
1032
-		if($char == 'u' || $char == 'U' || $char == 'x') {
1033
-			$res = html_entity_decode('&#x' . $seq . ';', ENT_QUOTES, 'utf-8');
1034
-		} elseif(is_numeric($char)) {
1035
-			$res = html_entity_decode('&#' . octdec($matches[1]) . ';', ENT_QUOTES, 'utf-8');
1036
-		} elseif(isset($map[$char])) {
1037
-			$res = $map[$char];
1038
-		} else {
1039
-			$res = $char; // something like \s or \0 or so, just return the character ("s" or "0")
1040
-		}
1030
+        $char = $matches[1][0];
1031
+        $seq = substr($matches[1], 1);
1032
+        if($char == 'u' || $char == 'U' || $char == 'x') {
1033
+            $res = html_entity_decode('&#x' . $seq . ';', ENT_QUOTES, 'utf-8');
1034
+        } elseif(is_numeric($char)) {
1035
+            $res = html_entity_decode('&#' . octdec($matches[1]) . ';', ENT_QUOTES, 'utf-8');
1036
+        } elseif(isset($map[$char])) {
1037
+            $res = $map[$char];
1038
+        } else {
1039
+            $res = $char; // something like \s or \0 or so, just return the character ("s" or "0")
1040
+        }
1041 1041
 		
1042
-		return $res;
1043
-	}
1042
+        return $res;
1043
+    }
1044 1044
 }
1045 1045
 
1046 1046
 ?>
1047 1047
\ No newline at end of file
Please login to merge, or discard this patch.
src/config/RbacDefinitionConfigHandler.class.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@
 block discarded – undo
77 77
 	/**
78 78
 	 * Parse a 'roles' node.
79 79
 	 *
80
-	 * @param      mixed  $roles  The "roles" node (element or node list)
80
+	 * @param      \DOMNodeList  $roles  The "roles" node (element or node list)
81 81
 	 * @param      string $parent The name of the parent role, or null.
82 82
 	 * @param      array  $data   A reference to the output data array.
83 83
 	 *
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -61,8 +61,8 @@  discard block
 block discarded – undo
61 61
 		
62 62
 		$data = array();
63 63
 
64
-		foreach($document->getConfigurationElements() as $cfg) {
65
-			if(!$cfg->has('roles')) {
64
+		foreach ($document->getConfigurationElements() as $cfg) {
65
+			if (!$cfg->has('roles')) {
66 66
 				continue;
67 67
 			}
68 68
 			
@@ -87,18 +87,18 @@  discard block
 block discarded – undo
87 87
 	protected function parseRoles($roles, $parent, &$data)
88 88
 	{
89 89
 		/** @var XmlConfigDomElement $role */
90
-		foreach($roles as $role) {
90
+		foreach ($roles as $role) {
91 91
 			$name = $role->getAttribute('name');
92 92
 			$entry = array();
93 93
 			$entry['parent'] = $parent;
94 94
 			$entry['permissions'] = array();
95
-			if($role->has('permissions')) {
95
+			if ($role->has('permissions')) {
96 96
 				/** @var XmlConfigDomElement $permission */
97
-				foreach($role->get('permissions') as $permission) {
97
+				foreach ($role->get('permissions') as $permission) {
98 98
 					$entry['permissions'][] = $permission->getValue();
99 99
 				}
100 100
 			}
101
-			if($role->has('roles')) {
101
+			if ($role->has('roles')) {
102 102
 				$this->parseRoles($role->get('roles'), $name, $data);
103 103
 			}
104 104
 			$data[$name] = $entry;
Please login to merge, or discard this patch.
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -36,74 +36,74 @@
 block discarded – undo
36 36
  */
37 37
 class RbacDefinitionConfigHandler extends XmlConfigHandler
38 38
 {
39
-	const XML_NAMESPACE = 'http://agavi.org/agavi/config/parts/rbac_definitions/1.1';
39
+    const XML_NAMESPACE = 'http://agavi.org/agavi/config/parts/rbac_definitions/1.1';
40 40
 	
41
-	/**
42
-	 * Execute this configuration handler.
43
-	 *
44
-	 * @param      XmlConfigDomDocument $document The document to parse.
45
-	 *
46
-	 * @return     string Data to be written to a cache file.
47
-	 *
48
-	 * @throws     <b>UnreadableException</b> If a requested configuration
49
-	 *                                        file does not exist or is not
50
-	 *                                        readable.
51
-	 * @throws     <b>ParseException</b> If a requested configuration file is
52
-	 *                                   improperly formatted.
53
-	 *
54
-	 * @author     David Zülke <[email protected]>
55
-	 * @since      0.11.0
56
-	 */
57
-	public function execute(XmlConfigDomDocument $document)
58
-	{
59
-		// set up our default namespace
60
-		$document->setDefaultNamespace(self::XML_NAMESPACE, 'rbac_definitions');
41
+    /**
42
+     * Execute this configuration handler.
43
+     *
44
+     * @param      XmlConfigDomDocument $document The document to parse.
45
+     *
46
+     * @return     string Data to be written to a cache file.
47
+     *
48
+     * @throws     <b>UnreadableException</b> If a requested configuration
49
+     *                                        file does not exist or is not
50
+     *                                        readable.
51
+     * @throws     <b>ParseException</b> If a requested configuration file is
52
+     *                                   improperly formatted.
53
+     *
54
+     * @author     David Zülke <[email protected]>
55
+     * @since      0.11.0
56
+     */
57
+    public function execute(XmlConfigDomDocument $document)
58
+    {
59
+        // set up our default namespace
60
+        $document->setDefaultNamespace(self::XML_NAMESPACE, 'rbac_definitions');
61 61
 		
62
-		$data = array();
62
+        $data = array();
63 63
 
64
-		foreach($document->getConfigurationElements() as $cfg) {
65
-			if(!$cfg->has('roles')) {
66
-				continue;
67
-			}
64
+        foreach($document->getConfigurationElements() as $cfg) {
65
+            if(!$cfg->has('roles')) {
66
+                continue;
67
+            }
68 68
 			
69
-			$this->parseRoles($cfg->get('roles'), null, $data);
70
-		}
69
+            $this->parseRoles($cfg->get('roles'), null, $data);
70
+        }
71 71
 
72
-		$code = "return " . var_export($data, true) . ";";
72
+        $code = "return " . var_export($data, true) . ";";
73 73
 		
74
-		return $this->generate($code, $document->documentURI);
75
-	}
74
+        return $this->generate($code, $document->documentURI);
75
+    }
76 76
 	
77
-	/**
78
-	 * Parse a 'roles' node.
79
-	 *
80
-	 * @param      mixed  $roles  The "roles" node (element or node list)
81
-	 * @param      string $parent The name of the parent role, or null.
82
-	 * @param      array  $data   A reference to the output data array.
83
-	 *
84
-	 * @author     David Zülke <[email protected]>
85
-	 * @since      0.11.0
86
-	 */
87
-	protected function parseRoles($roles, $parent, &$data)
88
-	{
89
-		/** @var XmlConfigDomElement $role */
90
-		foreach($roles as $role) {
91
-			$name = $role->getAttribute('name');
92
-			$entry = array();
93
-			$entry['parent'] = $parent;
94
-			$entry['permissions'] = array();
95
-			if($role->has('permissions')) {
96
-				/** @var XmlConfigDomElement $permission */
97
-				foreach($role->get('permissions') as $permission) {
98
-					$entry['permissions'][] = $permission->getValue();
99
-				}
100
-			}
101
-			if($role->has('roles')) {
102
-				$this->parseRoles($role->get('roles'), $name, $data);
103
-			}
104
-			$data[$name] = $entry;
105
-		}
106
-	}
77
+    /**
78
+     * Parse a 'roles' node.
79
+     *
80
+     * @param      mixed  $roles  The "roles" node (element or node list)
81
+     * @param      string $parent The name of the parent role, or null.
82
+     * @param      array  $data   A reference to the output data array.
83
+     *
84
+     * @author     David Zülke <[email protected]>
85
+     * @since      0.11.0
86
+     */
87
+    protected function parseRoles($roles, $parent, &$data)
88
+    {
89
+        /** @var XmlConfigDomElement $role */
90
+        foreach($roles as $role) {
91
+            $name = $role->getAttribute('name');
92
+            $entry = array();
93
+            $entry['parent'] = $parent;
94
+            $entry['permissions'] = array();
95
+            if($role->has('permissions')) {
96
+                /** @var XmlConfigDomElement $permission */
97
+                foreach($role->get('permissions') as $permission) {
98
+                    $entry['permissions'][] = $permission->getValue();
99
+                }
100
+            }
101
+            if($role->has('roles')) {
102
+                $this->parseRoles($role->get('roles'), $name, $data);
103
+            }
104
+            $data[$name] = $entry;
105
+        }
106
+    }
107 107
 }
108 108
 
109 109
 ?>
110 110
\ No newline at end of file
Please login to merge, or discard this patch.
src/config/RoutingConfigHandler.class.php 4 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,6 @@
 block discarded – undo
16 16
 namespace Agavi\Config;
17 17
 
18 18
 use Agavi\Config\Util\Dom\XmlConfigDomElement;
19
-use Agavi\Config\Util\Dom\XmlConfigDomNode;
20 19
 use Agavi\Core\Context;
21 20
 use Agavi\Config\XmlConfigHandler;
22 21
 use Agavi\Config\Util\Dom\XmlConfigDomDocument;
Please login to merge, or discard this patch.
Indentation   +136 added lines, -136 removed lines patch added patch discarded remove patch
@@ -42,149 +42,149 @@
 block discarded – undo
42 42
  */
43 43
 class RoutingConfigHandler extends XmlConfigHandler
44 44
 {
45
-	const XML_NAMESPACE = 'http://agavi.org/agavi/config/parts/routing/1.1';
45
+    const XML_NAMESPACE = 'http://agavi.org/agavi/config/parts/routing/1.1';
46 46
 	
47
-	/**
48
-	 * @var        array Stores the generated names of unnamed routes.
49
-	 */
50
-	protected $unnamedRoutes = array();
47
+    /**
48
+     * @var        array Stores the generated names of unnamed routes.
49
+     */
50
+    protected $unnamedRoutes = array();
51 51
 	
52
-	/**
53
-	 * Execute this configuration handler.
54
-	 *
55
-	 * @param      XmlConfigDomDocument $document The document to parse.
56
-	 *
57
-	 * @return     string Data to be written to a cache file.
58
-	 *
59
-	 * @throws     <b>UnreadableException</b> If a requested configuration
60
-	 *                                             file does not exist or is not
61
-	 *                                             readable.
62
-	 * @throws     <b>ParseException</b> If a requested configuration file is
63
-	 *                                        improperly formatted.
64
-	 *
65
-	 * @author     Dominik del Bondio <[email protected]>
66
-	 * @author     David Zülke <[email protected]>
67
-	 * @since      0.11.0
68
-	 */
69
-	public function execute(XmlConfigDomDocument $document)
70
-	{
71
-		// set up our default namespace
72
-		$document->setDefaultNamespace(self::XML_NAMESPACE, 'routing');
52
+    /**
53
+     * Execute this configuration handler.
54
+     *
55
+     * @param      XmlConfigDomDocument $document The document to parse.
56
+     *
57
+     * @return     string Data to be written to a cache file.
58
+     *
59
+     * @throws     <b>UnreadableException</b> If a requested configuration
60
+     *                                             file does not exist or is not
61
+     *                                             readable.
62
+     * @throws     <b>ParseException</b> If a requested configuration file is
63
+     *                                        improperly formatted.
64
+     *
65
+     * @author     Dominik del Bondio <[email protected]>
66
+     * @author     David Zülke <[email protected]>
67
+     * @since      0.11.0
68
+     */
69
+    public function execute(XmlConfigDomDocument $document)
70
+    {
71
+        // set up our default namespace
72
+        $document->setDefaultNamespace(self::XML_NAMESPACE, 'routing');
73 73
 		
74
-		$routing = Context::getInstance($this->context)->getRouting();
74
+        $routing = Context::getInstance($this->context)->getRouting();
75 75
 
76
-		// reset the stored route names
77
-		$this->unnamedRoutes = array();
76
+        // reset the stored route names
77
+        $this->unnamedRoutes = array();
78 78
 
79
-		// clear the routing
80
-		$routing->importRoutes(array());
79
+        // clear the routing
80
+        $routing->importRoutes(array());
81 81
 		
82
-		foreach($document->getConfigurationElements() as $cfg) {
83
-			if($cfg->has('routes')) {
84
-				$this->parseRoutes($routing, $cfg->get('routes'));
85
-			}
86
-		}
87
-
88
-		// we cannot do this:
89
-		// $code = '$this->importRoutes(unserialize(' . var_export(serialize($routing->exportRoutes()), true) . '));';
90
-		// return $this->generate($code, $document->documentURI);
91
-		// because var_export() incorrectly escapes null-byte sequences as \000, which results in a corrupted string, and unserialize() doesn't like corrupted strings
92
-		// this was fixed in PHP 5.2.6, but we're compatible with 5.2.0+
93
-		// see http://bugs.php.net/bug.php?id=37262 and http://bugs.php.net/bug.php?id=42272
82
+        foreach($document->getConfigurationElements() as $cfg) {
83
+            if($cfg->has('routes')) {
84
+                $this->parseRoutes($routing, $cfg->get('routes'));
85
+            }
86
+        }
87
+
88
+        // we cannot do this:
89
+        // $code = '$this->importRoutes(unserialize(' . var_export(serialize($routing->exportRoutes()), true) . '));';
90
+        // return $this->generate($code, $document->documentURI);
91
+        // because var_export() incorrectly escapes null-byte sequences as \000, which results in a corrupted string, and unserialize() doesn't like corrupted strings
92
+        // this was fixed in PHP 5.2.6, but we're compatible with 5.2.0+
93
+        // see http://bugs.php.net/bug.php?id=37262 and http://bugs.php.net/bug.php?id=42272
94 94
 		
95
-		return serialize($routing->exportRoutes());
96
-	}
97
-
98
-	/**
99
-	 * Takes a nested array of AgaviConfigValueHolder containing the routing
100
-	 * information and creates the routes in the given routing.
101
-	 *
102
-	 * @param      Routing               $routing The routing instance to create the routes in.
103
-	 * @param      XmlConfigDomElement[] $routes  The "routes" node (element or node list)
104
-	 * @param      string                $parent  The name of the parent route (if any).
105
-	 *
106
-	 * @author     Dominik del Bondio <[email protected]>
107
-	 * @since      0.11.0
108
-	 */
109
-	protected function parseRoutes(Routing $routing, $routes, $parent = null)
110
-	{
111
-		foreach($routes as $route) {
112
-			$pattern = Toolkit::expandDirectives($route->getAttribute('pattern'));
113
-			$opts = array();
114
-			if($route->hasAttribute('imply'))					$opts['imply']				= Toolkit::literalize($route->getAttribute('imply'));
115
-			if($route->hasAttribute('cut'))						$opts['cut']					= Toolkit::literalize($route->getAttribute('cut'));
116
-			if($route->hasAttribute('stop'))					$opts['stop']					= Toolkit::literalize($route->getAttribute('stop'));
117
-			if($route->hasAttribute('name'))					$opts['name']					= Toolkit::expandDirectives($route->getAttribute('name'));
118
-			if($route->hasAttribute('source'))				$opts['source']				= Toolkit::expandDirectives($route->getAttribute('source'));
119
-			if($route->hasAttribute('constraint'))		$opts['constraint']		= array_map('trim', explode(' ', trim(Toolkit::expandDirectives($route->getAttribute('constraint')))));
120
-			// values which will be set when the route matched
121
-			if($route->hasAttribute('controller'))				$opts['controller']				= Toolkit::expandDirectives($route->getAttribute('controller'));
122
-			if($route->hasAttribute('locale'))				$opts['locale']				= Toolkit::expandDirectives($route->getAttribute('locale'));
123
-			if($route->hasAttribute('method'))				$opts['method']				= Toolkit::expandDirectives($route->getAttribute('method'));
124
-			if($route->hasAttribute('module'))				$opts['module']				= Toolkit::expandDirectives($route->getAttribute('module'));
125
-			if($route->hasAttribute('output_type'))		$opts['output_type']	= Toolkit::expandDirectives($route->getAttribute('output_type'));
126
-
127
-			if($route->has('ignores')) {
128
-				/** @var XmlConfigDomElement $ignore */
129
-				foreach($route->get('ignores') as $ignore) {
130
-					$opts['ignores'][] = $ignore->getValue();
131
-				}
132
-			}
133
-
134
-			if($route->has('defaults')) {
135
-				/** @var XmlConfigDomElement $default */
136
-				foreach($route->get('defaults') as $default) {
137
-					$opts['defaults'][$default->getAttribute('for')] = $default->getValue();
138
-				}
139
-			}
140
-
141
-			if($route->has('callbacks')) {
142
-				$opts['callbacks'] = array();
143
-				/** @var XmlConfigDomElement $callback */
144
-				foreach($route->get('callbacks') as $callback) {
145
-					$opts['callbacks'][] = array(
146
-						'class' => $callback->getAttribute('class'),
147
-						'parameters' => $callback->getAgaviParameters(),
148
-					);
149
-				}
150
-			}
151
-
152
-			$opts['parameters'] = $route->getAgaviParameters();
153
-
154
-			if(isset($opts['name']) && $parent) {
155
-				// don't overwrite $parent since it's used later
156
-				$parentName = $parent;
157
-				if($opts['name'][0] == '.') {
158
-					while($parentName && isset($this->unnamedRoutes[$parentName])) {
159
-						$parentRoute = $routing->getRoute($parentName);
160
-						$parentName = $parentRoute['opt']['parent'];
161
-					}
162
-					$opts['name'] = $parentName . $opts['name'];
163
-				}
164
-			}
165
-
166
-			if(isset($opts['controller']) && $parent) {
167
-				if($opts['controller'][0] == '.') {
168
-					$parentRoute = $routing->getRoute($parent);
169
-					// unwind all empty 'controller' attributes of the parent(s)
170
-					while($parentRoute && empty($parentRoute['opt']['controller'])) {
171
-						$parentRoute = $routing->getRoute($parentRoute['opt']['parent']);
172
-					}
173
-					if(!empty($parentRoute['opt']['controller'])) {
174
-						$opts['controller'] = $parentRoute['opt']['controller'] . $opts['controller'];
175
-					}
176
-				}
177
-			}
178
-
179
-			$name = $routing->addRoute($pattern, $opts, $parent);
180
-			if(!isset($opts['name']) || $opts['name'] !== $name) {
181
-				$this->unnamedRoutes[$name] = true;
182
-			}
183
-			if($route->has('routes')) {
184
-				$this->parseRoutes($routing, $route->get('routes'), $name);
185
-			}
186
-		}
187
-	}
95
+        return serialize($routing->exportRoutes());
96
+    }
97
+
98
+    /**
99
+     * Takes a nested array of AgaviConfigValueHolder containing the routing
100
+     * information and creates the routes in the given routing.
101
+     *
102
+     * @param      Routing               $routing The routing instance to create the routes in.
103
+     * @param      XmlConfigDomElement[] $routes  The "routes" node (element or node list)
104
+     * @param      string                $parent  The name of the parent route (if any).
105
+     *
106
+     * @author     Dominik del Bondio <[email protected]>
107
+     * @since      0.11.0
108
+     */
109
+    protected function parseRoutes(Routing $routing, $routes, $parent = null)
110
+    {
111
+        foreach($routes as $route) {
112
+            $pattern = Toolkit::expandDirectives($route->getAttribute('pattern'));
113
+            $opts = array();
114
+            if($route->hasAttribute('imply'))					$opts['imply']				= Toolkit::literalize($route->getAttribute('imply'));
115
+            if($route->hasAttribute('cut'))						$opts['cut']					= Toolkit::literalize($route->getAttribute('cut'));
116
+            if($route->hasAttribute('stop'))					$opts['stop']					= Toolkit::literalize($route->getAttribute('stop'));
117
+            if($route->hasAttribute('name'))					$opts['name']					= Toolkit::expandDirectives($route->getAttribute('name'));
118
+            if($route->hasAttribute('source'))				$opts['source']				= Toolkit::expandDirectives($route->getAttribute('source'));
119
+            if($route->hasAttribute('constraint'))		$opts['constraint']		= array_map('trim', explode(' ', trim(Toolkit::expandDirectives($route->getAttribute('constraint')))));
120
+            // values which will be set when the route matched
121
+            if($route->hasAttribute('controller'))				$opts['controller']				= Toolkit::expandDirectives($route->getAttribute('controller'));
122
+            if($route->hasAttribute('locale'))				$opts['locale']				= Toolkit::expandDirectives($route->getAttribute('locale'));
123
+            if($route->hasAttribute('method'))				$opts['method']				= Toolkit::expandDirectives($route->getAttribute('method'));
124
+            if($route->hasAttribute('module'))				$opts['module']				= Toolkit::expandDirectives($route->getAttribute('module'));
125
+            if($route->hasAttribute('output_type'))		$opts['output_type']	= Toolkit::expandDirectives($route->getAttribute('output_type'));
126
+
127
+            if($route->has('ignores')) {
128
+                /** @var XmlConfigDomElement $ignore */
129
+                foreach($route->get('ignores') as $ignore) {
130
+                    $opts['ignores'][] = $ignore->getValue();
131
+                }
132
+            }
133
+
134
+            if($route->has('defaults')) {
135
+                /** @var XmlConfigDomElement $default */
136
+                foreach($route->get('defaults') as $default) {
137
+                    $opts['defaults'][$default->getAttribute('for')] = $default->getValue();
138
+                }
139
+            }
140
+
141
+            if($route->has('callbacks')) {
142
+                $opts['callbacks'] = array();
143
+                /** @var XmlConfigDomElement $callback */
144
+                foreach($route->get('callbacks') as $callback) {
145
+                    $opts['callbacks'][] = array(
146
+                        'class' => $callback->getAttribute('class'),
147
+                        'parameters' => $callback->getAgaviParameters(),
148
+                    );
149
+                }
150
+            }
151
+
152
+            $opts['parameters'] = $route->getAgaviParameters();
153
+
154
+            if(isset($opts['name']) && $parent) {
155
+                // don't overwrite $parent since it's used later
156
+                $parentName = $parent;
157
+                if($opts['name'][0] == '.') {
158
+                    while($parentName && isset($this->unnamedRoutes[$parentName])) {
159
+                        $parentRoute = $routing->getRoute($parentName);
160
+                        $parentName = $parentRoute['opt']['parent'];
161
+                    }
162
+                    $opts['name'] = $parentName . $opts['name'];
163
+                }
164
+            }
165
+
166
+            if(isset($opts['controller']) && $parent) {
167
+                if($opts['controller'][0] == '.') {
168
+                    $parentRoute = $routing->getRoute($parent);
169
+                    // unwind all empty 'controller' attributes of the parent(s)
170
+                    while($parentRoute && empty($parentRoute['opt']['controller'])) {
171
+                        $parentRoute = $routing->getRoute($parentRoute['opt']['parent']);
172
+                    }
173
+                    if(!empty($parentRoute['opt']['controller'])) {
174
+                        $opts['controller'] = $parentRoute['opt']['controller'] . $opts['controller'];
175
+                    }
176
+                }
177
+            }
178
+
179
+            $name = $routing->addRoute($pattern, $opts, $parent);
180
+            if(!isset($opts['name']) || $opts['name'] !== $name) {
181
+                $this->unnamedRoutes[$name] = true;
182
+            }
183
+            if($route->has('routes')) {
184
+                $this->parseRoutes($routing, $route->get('routes'), $name);
185
+            }
186
+        }
187
+    }
188 188
 }
189 189
 
190 190
 ?>
191 191
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -79,8 +79,8 @@  discard block
 block discarded – undo
79 79
 		// clear the routing
80 80
 		$routing->importRoutes(array());
81 81
 		
82
-		foreach($document->getConfigurationElements() as $cfg) {
83
-			if($cfg->has('routes')) {
82
+		foreach ($document->getConfigurationElements() as $cfg) {
83
+			if ($cfg->has('routes')) {
84 84
 				$this->parseRoutes($routing, $cfg->get('routes'));
85 85
 			}
86 86
 		}
@@ -108,40 +108,40 @@  discard block
 block discarded – undo
108 108
 	 */
109 109
 	protected function parseRoutes(Routing $routing, $routes, $parent = null)
110 110
 	{
111
-		foreach($routes as $route) {
111
+		foreach ($routes as $route) {
112 112
 			$pattern = Toolkit::expandDirectives($route->getAttribute('pattern'));
113 113
 			$opts = array();
114
-			if($route->hasAttribute('imply'))					$opts['imply']				= Toolkit::literalize($route->getAttribute('imply'));
115
-			if($route->hasAttribute('cut'))						$opts['cut']					= Toolkit::literalize($route->getAttribute('cut'));
116
-			if($route->hasAttribute('stop'))					$opts['stop']					= Toolkit::literalize($route->getAttribute('stop'));
117
-			if($route->hasAttribute('name'))					$opts['name']					= Toolkit::expandDirectives($route->getAttribute('name'));
118
-			if($route->hasAttribute('source'))				$opts['source']				= Toolkit::expandDirectives($route->getAttribute('source'));
119
-			if($route->hasAttribute('constraint'))		$opts['constraint']		= array_map('trim', explode(' ', trim(Toolkit::expandDirectives($route->getAttribute('constraint')))));
114
+			if ($route->hasAttribute('imply'))					$opts['imply'] = Toolkit::literalize($route->getAttribute('imply'));
115
+			if ($route->hasAttribute('cut'))						$opts['cut'] = Toolkit::literalize($route->getAttribute('cut'));
116
+			if ($route->hasAttribute('stop'))					$opts['stop']					= Toolkit::literalize($route->getAttribute('stop'));
117
+			if ($route->hasAttribute('name'))					$opts['name']					= Toolkit::expandDirectives($route->getAttribute('name'));
118
+			if ($route->hasAttribute('source'))				$opts['source'] = Toolkit::expandDirectives($route->getAttribute('source'));
119
+			if ($route->hasAttribute('constraint'))		$opts['constraint'] = array_map('trim', explode(' ', trim(Toolkit::expandDirectives($route->getAttribute('constraint')))));
120 120
 			// values which will be set when the route matched
121
-			if($route->hasAttribute('controller'))				$opts['controller']				= Toolkit::expandDirectives($route->getAttribute('controller'));
122
-			if($route->hasAttribute('locale'))				$opts['locale']				= Toolkit::expandDirectives($route->getAttribute('locale'));
123
-			if($route->hasAttribute('method'))				$opts['method']				= Toolkit::expandDirectives($route->getAttribute('method'));
124
-			if($route->hasAttribute('module'))				$opts['module']				= Toolkit::expandDirectives($route->getAttribute('module'));
125
-			if($route->hasAttribute('output_type'))		$opts['output_type']	= Toolkit::expandDirectives($route->getAttribute('output_type'));
121
+			if ($route->hasAttribute('controller'))				$opts['controller'] = Toolkit::expandDirectives($route->getAttribute('controller'));
122
+			if ($route->hasAttribute('locale'))				$opts['locale']				= Toolkit::expandDirectives($route->getAttribute('locale'));
123
+			if ($route->hasAttribute('method'))				$opts['method']				= Toolkit::expandDirectives($route->getAttribute('method'));
124
+			if ($route->hasAttribute('module'))				$opts['module']				= Toolkit::expandDirectives($route->getAttribute('module'));
125
+			if ($route->hasAttribute('output_type'))		$opts['output_type'] = Toolkit::expandDirectives($route->getAttribute('output_type'));
126 126
 
127
-			if($route->has('ignores')) {
127
+			if ($route->has('ignores')) {
128 128
 				/** @var XmlConfigDomElement $ignore */
129
-				foreach($route->get('ignores') as $ignore) {
129
+				foreach ($route->get('ignores') as $ignore) {
130 130
 					$opts['ignores'][] = $ignore->getValue();
131 131
 				}
132 132
 			}
133 133
 
134
-			if($route->has('defaults')) {
134
+			if ($route->has('defaults')) {
135 135
 				/** @var XmlConfigDomElement $default */
136
-				foreach($route->get('defaults') as $default) {
136
+				foreach ($route->get('defaults') as $default) {
137 137
 					$opts['defaults'][$default->getAttribute('for')] = $default->getValue();
138 138
 				}
139 139
 			}
140 140
 
141
-			if($route->has('callbacks')) {
141
+			if ($route->has('callbacks')) {
142 142
 				$opts['callbacks'] = array();
143 143
 				/** @var XmlConfigDomElement $callback */
144
-				foreach($route->get('callbacks') as $callback) {
144
+				foreach ($route->get('callbacks') as $callback) {
145 145
 					$opts['callbacks'][] = array(
146 146
 						'class' => $callback->getAttribute('class'),
147 147
 						'parameters' => $callback->getAgaviParameters(),
@@ -151,11 +151,11 @@  discard block
 block discarded – undo
151 151
 
152 152
 			$opts['parameters'] = $route->getAgaviParameters();
153 153
 
154
-			if(isset($opts['name']) && $parent) {
154
+			if (isset($opts['name']) && $parent) {
155 155
 				// don't overwrite $parent since it's used later
156 156
 				$parentName = $parent;
157
-				if($opts['name'][0] == '.') {
158
-					while($parentName && isset($this->unnamedRoutes[$parentName])) {
157
+				if ($opts['name'][0] == '.') {
158
+					while ($parentName && isset($this->unnamedRoutes[$parentName])) {
159 159
 						$parentRoute = $routing->getRoute($parentName);
160 160
 						$parentName = $parentRoute['opt']['parent'];
161 161
 					}
@@ -163,24 +163,24 @@  discard block
 block discarded – undo
163 163
 				}
164 164
 			}
165 165
 
166
-			if(isset($opts['controller']) && $parent) {
167
-				if($opts['controller'][0] == '.') {
166
+			if (isset($opts['controller']) && $parent) {
167
+				if ($opts['controller'][0] == '.') {
168 168
 					$parentRoute = $routing->getRoute($parent);
169 169
 					// unwind all empty 'controller' attributes of the parent(s)
170
-					while($parentRoute && empty($parentRoute['opt']['controller'])) {
170
+					while ($parentRoute && empty($parentRoute['opt']['controller'])) {
171 171
 						$parentRoute = $routing->getRoute($parentRoute['opt']['parent']);
172 172
 					}
173
-					if(!empty($parentRoute['opt']['controller'])) {
173
+					if (!empty($parentRoute['opt']['controller'])) {
174 174
 						$opts['controller'] = $parentRoute['opt']['controller'] . $opts['controller'];
175 175
 					}
176 176
 				}
177 177
 			}
178 178
 
179 179
 			$name = $routing->addRoute($pattern, $opts, $parent);
180
-			if(!isset($opts['name']) || $opts['name'] !== $name) {
180
+			if (!isset($opts['name']) || $opts['name'] !== $name) {
181 181
 				$this->unnamedRoutes[$name] = true;
182 182
 			}
183
-			if($route->has('routes')) {
183
+			if ($route->has('routes')) {
184 184
 				$this->parseRoutes($routing, $route->get('routes'), $name);
185 185
 			}
186 186
 		}
Please login to merge, or discard this patch.
Braces   +33 added lines, -11 removed lines patch added patch discarded remove patch
@@ -111,18 +111,40 @@
 block discarded – undo
111 111
 		foreach($routes as $route) {
112 112
 			$pattern = Toolkit::expandDirectives($route->getAttribute('pattern'));
113 113
 			$opts = array();
114
-			if($route->hasAttribute('imply'))					$opts['imply']				= Toolkit::literalize($route->getAttribute('imply'));
115
-			if($route->hasAttribute('cut'))						$opts['cut']					= Toolkit::literalize($route->getAttribute('cut'));
116
-			if($route->hasAttribute('stop'))					$opts['stop']					= Toolkit::literalize($route->getAttribute('stop'));
117
-			if($route->hasAttribute('name'))					$opts['name']					= Toolkit::expandDirectives($route->getAttribute('name'));
118
-			if($route->hasAttribute('source'))				$opts['source']				= Toolkit::expandDirectives($route->getAttribute('source'));
119
-			if($route->hasAttribute('constraint'))		$opts['constraint']		= array_map('trim', explode(' ', trim(Toolkit::expandDirectives($route->getAttribute('constraint')))));
114
+			if($route->hasAttribute('imply')) {
115
+			    $opts['imply']				= Toolkit::literalize($route->getAttribute('imply'));
116
+			}
117
+			if($route->hasAttribute('cut')) {
118
+			    $opts['cut']					= Toolkit::literalize($route->getAttribute('cut'));
119
+			}
120
+			if($route->hasAttribute('stop')) {
121
+			    $opts['stop']					= Toolkit::literalize($route->getAttribute('stop'));
122
+			}
123
+			if($route->hasAttribute('name')) {
124
+			    $opts['name']					= Toolkit::expandDirectives($route->getAttribute('name'));
125
+			}
126
+			if($route->hasAttribute('source')) {
127
+			    $opts['source']				= Toolkit::expandDirectives($route->getAttribute('source'));
128
+			}
129
+			if($route->hasAttribute('constraint')) {
130
+			    $opts['constraint']		= array_map('trim', explode(' ', trim(Toolkit::expandDirectives($route->getAttribute('constraint')))));
131
+			}
120 132
 			// values which will be set when the route matched
121
-			if($route->hasAttribute('controller'))				$opts['controller']				= Toolkit::expandDirectives($route->getAttribute('controller'));
122
-			if($route->hasAttribute('locale'))				$opts['locale']				= Toolkit::expandDirectives($route->getAttribute('locale'));
123
-			if($route->hasAttribute('method'))				$opts['method']				= Toolkit::expandDirectives($route->getAttribute('method'));
124
-			if($route->hasAttribute('module'))				$opts['module']				= Toolkit::expandDirectives($route->getAttribute('module'));
125
-			if($route->hasAttribute('output_type'))		$opts['output_type']	= Toolkit::expandDirectives($route->getAttribute('output_type'));
133
+			if($route->hasAttribute('controller')) {
134
+			    $opts['controller']				= Toolkit::expandDirectives($route->getAttribute('controller'));
135
+			}
136
+			if($route->hasAttribute('locale')) {
137
+			    $opts['locale']				= Toolkit::expandDirectives($route->getAttribute('locale'));
138
+			}
139
+			if($route->hasAttribute('method')) {
140
+			    $opts['method']				= Toolkit::expandDirectives($route->getAttribute('method'));
141
+			}
142
+			if($route->hasAttribute('module')) {
143
+			    $opts['module']				= Toolkit::expandDirectives($route->getAttribute('module'));
144
+			}
145
+			if($route->hasAttribute('output_type')) {
146
+			    $opts['output_type']	= Toolkit::expandDirectives($route->getAttribute('output_type'));
147
+			}
126 148
 
127 149
 			if($route->has('ignores')) {
128 150
 				/** @var XmlConfigDomElement $ignore */
Please login to merge, or discard this patch.
src/config/util/dom/XmlConfigDomDocument.class.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -235,7 +235,7 @@
 block discarded – undo
235 235
 	 * @param      bool     $deep Whether or not to recursively import the node's
236 236
 	 *                            subtree.
237 237
 	 *
238
-	 * @return     \DOMNode|XmlConfigDomNode|bool  The copied node, or false if it cannot be copied.
238
+	 * @return     \DOMNode  The copied node, or false if it cannot be copied.
239 239
 	 *
240 240
 	 * @author     Noah Fontes <[email protected]>
241 241
 	 * @since      1.0.0
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	{
88 88
 		parent::__construct($version, $encoding);
89 89
 		
90
-		foreach($this->nodeClassMap as $domClass => $agaviClass) {
90
+		foreach ($this->nodeClassMap as $domClass => $agaviClass) {
91 91
 			$this->registerNodeClass($domClass, $agaviClass);
92 92
 		}
93 93
 		
@@ -112,9 +112,9 @@  discard block
 block discarded – undo
112 112
 		
113 113
 		$result = parent::load($filename, $options);
114 114
 		
115
-		if(libxml_get_last_error() !== false) {
115
+		if (libxml_get_last_error() !== false) {
116 116
 			$errors = array();
117
-			foreach(libxml_get_errors() as $error) {
117
+			foreach (libxml_get_errors() as $error) {
118 118
 				$errors[] = sprintf('[%s #%d] Line %d: %s', $error->level == LIBXML_ERR_WARNING ? 'Warning' : ($error->level == LIBXML_ERR_ERROR ? 'Error' : 'Fatal'), $error->code, $error->line, $error->message);
119 119
 			}
120 120
 			libxml_clear_errors();
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 		
133 133
 		$this->xpath = new \DOMXPath($this);
134 134
 		
135
-		if($this->isAgaviConfiguration()) {
135
+		if ($this->isAgaviConfiguration()) {
136 136
 			XmlConfigParser::registerAgaviNamespaces($this);
137 137
 		}
138 138
 		
@@ -157,9 +157,9 @@  discard block
 block discarded – undo
157 157
 		
158 158
 		$result = parent::loadXML($source, $options);
159 159
 		
160
-		if(libxml_get_last_error() !== false) {
160
+		if (libxml_get_last_error() !== false) {
161 161
 			$errors = array();
162
-			foreach(libxml_get_errors() as $error) {
162
+			foreach (libxml_get_errors() as $error) {
163 163
 				$errors[] = sprintf('[%s #%d] Line %d: %s', $error->level == LIBXML_ERR_WARNING ? 'Warning' : ($error->level == LIBXML_ERR_ERROR ? 'Error' : 'Fatal'), $error->code, $error->line, $error->message);
164 164
 			}
165 165
 			libxml_clear_errors();
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 		
178 178
 		$this->xpath = new \DOMXPath($this);
179 179
 		
180
-		if($this->isAgaviConfiguration()) {
180
+		if ($this->isAgaviConfiguration()) {
181 181
 			XmlConfigParser::registerAgaviNamespaces($this);
182 182
 		}
183 183
 		
@@ -201,17 +201,17 @@  discard block
 block discarded – undo
201 201
 		
202 202
 		$result = parent::xinclude($options);
203 203
 		
204
-		if(libxml_get_last_error() !== false) {
204
+		if (libxml_get_last_error() !== false) {
205 205
 			$throw = false;
206 206
 			$errors = array();
207
-			foreach(libxml_get_errors() as $error) {
208
-				if($error->level != LIBXML_ERR_WARNING) {
207
+			foreach (libxml_get_errors() as $error) {
208
+				if ($error->level != LIBXML_ERR_WARNING) {
209 209
 					$throw = true;
210 210
 				}
211 211
 				$errors[] = sprintf('[%s #%d] Line %d: %s', $error->level == LIBXML_ERR_WARNING ? 'Warning' : ($error->level == LIBXML_ERR_ERROR ? 'Error' : 'Fatal'), $error->code, $error->line, $error->message);
212 212
 			}
213 213
 			libxml_clear_errors();
214
-			if($throw) {
214
+			if ($throw) {
215 215
 				libxml_use_internal_errors($luie);
216 216
 				throw new \DOMException(
217 217
 					sprintf(
@@ -247,9 +247,9 @@  discard block
 block discarded – undo
247 247
 		
248 248
 		$result = parent::importNode($node, $deep);
249 249
 		
250
-		if(libxml_get_last_error() !== false) {
250
+		if (libxml_get_last_error() !== false) {
251 251
 			$errors = array();
252
-			foreach(libxml_get_errors() as $error) {
252
+			foreach (libxml_get_errors() as $error) {
253 253
 				$errors[] = sprintf('[%s #%d] Line %d: %s', $error->level == LIBXML_ERR_WARNING ? 'Warning' : ($error->level == LIBXML_ERR_ERROR ? 'Error' : 'Fatal'), $error->code, $error->line, $error->message);
254 254
 			}
255 255
 			libxml_clear_errors();
@@ -285,9 +285,9 @@  discard block
 block discarded – undo
285 285
 		libxml_clear_errors();
286 286
 		
287 287
 		// gotta do the @ to suppress PHP warnings when the schema cannot be loaded or is invalid
288
-		if(!$result = @parent::schemaValidate($filename)) {
288
+		if (!$result = @parent::schemaValidate($filename)) {
289 289
 			$errors = array();
290
-			foreach(libxml_get_errors() as $error) {
290
+			foreach (libxml_get_errors() as $error) {
291 291
 				$errors[] = sprintf('[%s #%d] Line %d: %s', $error->level == LIBXML_ERR_WARNING ? 'Warning' : ($error->level == LIBXML_ERR_ERROR ? 'Error' : 'Fatal'), $error->code, $error->line, $error->message);
292 292
 			}
293 293
 			libxml_clear_errors();
@@ -323,9 +323,9 @@  discard block
 block discarded – undo
323 323
 		libxml_clear_errors();
324 324
 		
325 325
 		// gotta do the @ to suppress PHP warnings when the schema cannot be loaded or is invalid
326
-		if(!$result = @parent::schemaValidateSource($source)) {
326
+		if (!$result = @parent::schemaValidateSource($source)) {
327 327
 			$errors = array();
328
-			foreach(libxml_get_errors() as $error) {
328
+			foreach (libxml_get_errors() as $error) {
329 329
 				$errors[] = sprintf('[%s #%d] Line %d: %s', $error->level == LIBXML_ERR_WARNING ? 'Warning' : ($error->level == LIBXML_ERR_ERROR ? 'Error' : 'Fatal'), $error->code, $error->line, $error->message);
330 330
 			}
331 331
 			libxml_clear_errors();
@@ -360,9 +360,9 @@  discard block
 block discarded – undo
360 360
 		libxml_clear_errors();
361 361
 		
362 362
 		// gotta do the @ to suppress PHP warnings when the schema cannot be loaded or is invalid
363
-		if(!$result = @parent::relaxNGValidate($filename)) {
363
+		if (!$result = @parent::relaxNGValidate($filename)) {
364 364
 			$errors = array();
365
-			foreach(libxml_get_errors() as $error) {
365
+			foreach (libxml_get_errors() as $error) {
366 366
 				$errors[] = sprintf('[%s #%d] Line %d: %s', $error->level == LIBXML_ERR_WARNING ? 'Warning' : ($error->level == LIBXML_ERR_ERROR ? 'Error' : 'Fatal'), $error->code, $error->line, $error->message);
367 367
 			}
368 368
 			libxml_clear_errors();
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
 	 */
467 467
 	public function getAgaviEnvelopeNamespace()
468 468
 	{
469
-		if($this->isAgaviConfiguration()) {
469
+		if ($this->isAgaviConfiguration()) {
470 470
 			return $this->documentElement->namespaceURI;
471 471
 		}
472 472
 	}
@@ -484,11 +484,11 @@  discard block
 block discarded – undo
484 484
 	{
485 485
 		$retval = array();
486 486
 		
487
-		if($this->isAgaviConfiguration()) {
487
+		if ($this->isAgaviConfiguration()) {
488 488
 			$agaviNs = $this->getAgaviEnvelopeNamespace();
489 489
 			
490
-			foreach($this->documentElement->childNodes as $node) {
491
-				if($node->nodeType == XML_ELEMENT_NODE && $node->localName == 'configuration' && $node->namespaceURI == $agaviNs) {
490
+			foreach ($this->documentElement->childNodes as $node) {
491
+				if ($node->nodeType == XML_ELEMENT_NODE && $node->localName == 'configuration' && $node->namespaceURI == $agaviNs) {
492 492
 					$retval[] = $node;
493 493
 				}
494 494
 			}
@@ -507,11 +507,11 @@  discard block
 block discarded – undo
507 507
 	 */
508 508
 	public function getSandbox()
509 509
 	{
510
-		if($this->isAgaviConfiguration()) {
510
+		if ($this->isAgaviConfiguration()) {
511 511
 			$agaviNs = $this->getAgaviEnvelopeNamespace();
512 512
 			
513
-			foreach($this->documentElement->childNodes as $node) {
514
-				if($node->nodeType == XML_ELEMENT_NODE && $node->localName == 'sandbox' && $node->namespaceURI == $agaviNs) {
513
+			foreach ($this->documentElement->childNodes as $node) {
514
+				if ($node->nodeType == XML_ELEMENT_NODE && $node->localName == 'sandbox' && $node->namespaceURI == $agaviNs) {
515 515
 					return $node;
516 516
 				}
517 517
 			}
Please login to merge, or discard this patch.
Indentation   +461 added lines, -461 removed lines patch added patch discarded remove patch
@@ -35,488 +35,488 @@
 block discarded – undo
35 35
  */
36 36
 class XmlConfigDomDocument extends \DOMDocument
37 37
 {
38
-	/**
39
-	 * @var        string Default namespace used by several convenience methods in
40
-	 *                    other node classes to access/retrieve elements.
41
-	 */
42
-	protected $defaultNamespaceUri = '';
38
+    /**
39
+     * @var        string Default namespace used by several convenience methods in
40
+     *                    other node classes to access/retrieve elements.
41
+     */
42
+    protected $defaultNamespaceUri = '';
43 43
 	
44
-	/**
45
-	 * @var        string XPath prefix of the default namespace defined above.
46
-	 */
47
-	protected $defaultNamespacePrefix = '';
44
+    /**
45
+     * @var        string XPath prefix of the default namespace defined above.
46
+     */
47
+    protected $defaultNamespacePrefix = '';
48 48
 	
49
-	/**
50
-	 * @var        \DOMXPath A DOMXPath instance for this document.
51
-	 */
52
-	protected $xpath = null;
49
+    /**
50
+     * @var        \DOMXPath A DOMXPath instance for this document.
51
+     */
52
+    protected $xpath = null;
53 53
 	
54
-	/**
55
-	 * @var        array A map of DOM classes and extended Agavi implementations.
56
-	 */
57
-	protected $nodeClassMap = array(
58
-		'\\DOMAttr'                  => 'Agavi\\Config\\Util\\Dom\\XmlConfigDomAttr',
59
-		'\\DOMCharacterData'         => 'Agavi\\Config\\Util\\Dom\\XmlConfigDomCharacterData',
60
-		'\\DOMComment'               => 'Agavi\\Config\\Util\\Dom\\XmlConfigDomComment',
61
-		// yes, even DOMDocument, so we don't get back a vanilla DOMDocument when doing $doc->documentElement etc
62
-		'\\DOMDocument'              => 'Agavi\\Config\\Util\\Dom\\XmlConfigDomDocument',
63
-		'\\DOMDocumentFragment'      => 'Agavi\\Config\\Util\\Dom\\XmlConfigDomDocumentFragment',
64
-		'\\DOMDocumentType'          => 'Agavi\\Config\\Util\\Dom\\XmlConfigDomDocumentType',
65
-		'\\DOMElement'               => 'Agavi\\Config\\Util\\Dom\\XmlConfigDomElement',
66
-		'\\DOMEntity'                => 'Agavi\\Config\\Util\\Dom\\XmlConfigDomEntity',
67
-		'\\DOMEntityReference'       => 'Agavi\\Config\\Util\\Dom\\XmlConfigDomEntityReference',
68
-		'\\DOMNode'                  => 'Agavi\\Config\\Util\\Dom\\XmlConfigDomNode',
69
-		// 'DOMNotation'              => 'XmlConfigDomNotation',
70
-		'\\DOMProcessingInstruction' => 'Agavi\\Config\\Util\\Dom\\XmlConfigDomProcessingInstruction',
71
-		'\\DOMText'                  => 'Agavi\\Config\\Util\\Dom\\XmlConfigDomText',
72
-	);
54
+    /**
55
+     * @var        array A map of DOM classes and extended Agavi implementations.
56
+     */
57
+    protected $nodeClassMap = array(
58
+        '\\DOMAttr'                  => 'Agavi\\Config\\Util\\Dom\\XmlConfigDomAttr',
59
+        '\\DOMCharacterData'         => 'Agavi\\Config\\Util\\Dom\\XmlConfigDomCharacterData',
60
+        '\\DOMComment'               => 'Agavi\\Config\\Util\\Dom\\XmlConfigDomComment',
61
+        // yes, even DOMDocument, so we don't get back a vanilla DOMDocument when doing $doc->documentElement etc
62
+        '\\DOMDocument'              => 'Agavi\\Config\\Util\\Dom\\XmlConfigDomDocument',
63
+        '\\DOMDocumentFragment'      => 'Agavi\\Config\\Util\\Dom\\XmlConfigDomDocumentFragment',
64
+        '\\DOMDocumentType'          => 'Agavi\\Config\\Util\\Dom\\XmlConfigDomDocumentType',
65
+        '\\DOMElement'               => 'Agavi\\Config\\Util\\Dom\\XmlConfigDomElement',
66
+        '\\DOMEntity'                => 'Agavi\\Config\\Util\\Dom\\XmlConfigDomEntity',
67
+        '\\DOMEntityReference'       => 'Agavi\\Config\\Util\\Dom\\XmlConfigDomEntityReference',
68
+        '\\DOMNode'                  => 'Agavi\\Config\\Util\\Dom\\XmlConfigDomNode',
69
+        // 'DOMNotation'              => 'XmlConfigDomNotation',
70
+        '\\DOMProcessingInstruction' => 'Agavi\\Config\\Util\\Dom\\XmlConfigDomProcessingInstruction',
71
+        '\\DOMText'                  => 'Agavi\\Config\\Util\\Dom\\XmlConfigDomText',
72
+    );
73 73
 	
74
-	/**
75
-	 * The constructor.
76
-	 * Will auto-register Agavi DOM node classes and create an XPath instance.
77
-	 *
78
-	 * @param      string $version  The XML version.
79
-	 * @param      string $encoding The XML encoding.
80
-	 *
81
-	 * @see        DOMDocument::__construct()
82
-	 *
83
-	 * @author     David Zülke <[email protected]>
84
-	 * @since      1.0.0
85
-	 */
86
-	public function __construct($version = "1.0", $encoding = "UTF-8")
87
-	{
88
-		parent::__construct($version, $encoding);
89
-		
90
-		foreach($this->nodeClassMap as $domClass => $agaviClass) {
91
-			$this->registerNodeClass($domClass, $agaviClass);
92
-		}
93
-		
94
-		$this->xpath = new \DOMXPath($this);
95
-	}
74
+    /**
75
+     * The constructor.
76
+     * Will auto-register Agavi DOM node classes and create an XPath instance.
77
+     *
78
+     * @param      string $version  The XML version.
79
+     * @param      string $encoding The XML encoding.
80
+     *
81
+     * @see        DOMDocument::__construct()
82
+     *
83
+     * @author     David Zülke <[email protected]>
84
+     * @since      1.0.0
85
+     */
86
+    public function __construct($version = "1.0", $encoding = "UTF-8")
87
+    {
88
+        parent::__construct($version, $encoding);
89
+		
90
+        foreach($this->nodeClassMap as $domClass => $agaviClass) {
91
+            $this->registerNodeClass($domClass, $agaviClass);
92
+        }
93
+		
94
+        $this->xpath = new \DOMXPath($this);
95
+    }
96 96
 	
97
-	/**
98
-	 * Load XML from a file.
99
-	 *
100
-	 * @param      string $filename The path to the XML document.
101
-	 * @param      int    $options  Bitwise OR of the libxml option constants.
102
-	 *
103
-	 * @return     bool True of the operation is successful; false otherwise.
104
-	 *
105
-	 * @author     Noah Fontes <[email protected]>
106
-	 * @since      1.0.0
107
-	 */
108
-	public function load($filename, $options = 0)
109
-	{
110
-		$luie = libxml_use_internal_errors(true);
111
-		libxml_clear_errors();
112
-		
113
-		$result = parent::load($filename, $options);
114
-		
115
-		if(libxml_get_last_error() !== false) {
116
-			$errors = array();
117
-			foreach(libxml_get_errors() as $error) {
118
-				$errors[] = sprintf('[%s #%d] Line %d: %s', $error->level == LIBXML_ERR_WARNING ? 'Warning' : ($error->level == LIBXML_ERR_ERROR ? 'Error' : 'Fatal'), $error->code, $error->line, $error->message);
119
-			}
120
-			libxml_clear_errors();
121
-			libxml_use_internal_errors($luie);
122
-			throw new \DOMException(
123
-				sprintf(
124
-					'Error%s occurred while parsing the document: ' . "\n\n%s",
125
-					count($errors) > 1 ? 's' : '',
126
-					implode("\n", $errors)
127
-				)
128
-			);
129
-		}
130
-		
131
-		libxml_use_internal_errors($luie);
132
-		
133
-		$this->xpath = new \DOMXPath($this);
134
-		
135
-		if($this->isAgaviConfiguration()) {
136
-			XmlConfigParser::registerAgaviNamespaces($this);
137
-		}
138
-		
139
-		return $result;
140
-	}
97
+    /**
98
+     * Load XML from a file.
99
+     *
100
+     * @param      string $filename The path to the XML document.
101
+     * @param      int    $options  Bitwise OR of the libxml option constants.
102
+     *
103
+     * @return     bool True of the operation is successful; false otherwise.
104
+     *
105
+     * @author     Noah Fontes <[email protected]>
106
+     * @since      1.0.0
107
+     */
108
+    public function load($filename, $options = 0)
109
+    {
110
+        $luie = libxml_use_internal_errors(true);
111
+        libxml_clear_errors();
112
+		
113
+        $result = parent::load($filename, $options);
114
+		
115
+        if(libxml_get_last_error() !== false) {
116
+            $errors = array();
117
+            foreach(libxml_get_errors() as $error) {
118
+                $errors[] = sprintf('[%s #%d] Line %d: %s', $error->level == LIBXML_ERR_WARNING ? 'Warning' : ($error->level == LIBXML_ERR_ERROR ? 'Error' : 'Fatal'), $error->code, $error->line, $error->message);
119
+            }
120
+            libxml_clear_errors();
121
+            libxml_use_internal_errors($luie);
122
+            throw new \DOMException(
123
+                sprintf(
124
+                    'Error%s occurred while parsing the document: ' . "\n\n%s",
125
+                    count($errors) > 1 ? 's' : '',
126
+                    implode("\n", $errors)
127
+                )
128
+            );
129
+        }
130
+		
131
+        libxml_use_internal_errors($luie);
132
+		
133
+        $this->xpath = new \DOMXPath($this);
134
+		
135
+        if($this->isAgaviConfiguration()) {
136
+            XmlConfigParser::registerAgaviNamespaces($this);
137
+        }
138
+		
139
+        return $result;
140
+    }
141 141
 	
142
-	/**
143
-	 * Load XML from a string.
144
-	 *
145
-	 * @param      string $source  The string containing the XML.
146
-	 * @param      int    $options Bitwise OR of the libxml option constants.
147
-	 *
148
-	 * @return     bool True of the operation is successful; false otherwise.
149
-	 *
150
-	 * @author     Noah Fontes <[email protected]>
151
-	 * @since      1.0.0
152
-	 */
153
-	public function loadXml($source, $options = 0)
154
-	{
155
-		$luie = libxml_use_internal_errors(true);
156
-		libxml_clear_errors();
157
-		
158
-		$result = parent::loadXML($source, $options);
159
-		
160
-		if(libxml_get_last_error() !== false) {
161
-			$errors = array();
162
-			foreach(libxml_get_errors() as $error) {
163
-				$errors[] = sprintf('[%s #%d] Line %d: %s', $error->level == LIBXML_ERR_WARNING ? 'Warning' : ($error->level == LIBXML_ERR_ERROR ? 'Error' : 'Fatal'), $error->code, $error->line, $error->message);
164
-			}
165
-			libxml_clear_errors();
166
-			libxml_use_internal_errors($luie);
167
-			throw new \DOMException(
168
-				sprintf(
169
-					'Error%s occurred while parsing the document: ' . "\n\n%s",
170
-					count($errors) > 1 ? 's' : '',
171
-					implode("\n", $errors)
172
-				)
173
-			);
174
-		}
175
-		
176
-		libxml_use_internal_errors($luie);
177
-		
178
-		$this->xpath = new \DOMXPath($this);
179
-		
180
-		if($this->isAgaviConfiguration()) {
181
-			XmlConfigParser::registerAgaviNamespaces($this);
182
-		}
183
-		
184
-		return $result;
185
-	}
142
+    /**
143
+     * Load XML from a string.
144
+     *
145
+     * @param      string $source  The string containing the XML.
146
+     * @param      int    $options Bitwise OR of the libxml option constants.
147
+     *
148
+     * @return     bool True of the operation is successful; false otherwise.
149
+     *
150
+     * @author     Noah Fontes <[email protected]>
151
+     * @since      1.0.0
152
+     */
153
+    public function loadXml($source, $options = 0)
154
+    {
155
+        $luie = libxml_use_internal_errors(true);
156
+        libxml_clear_errors();
157
+		
158
+        $result = parent::loadXML($source, $options);
159
+		
160
+        if(libxml_get_last_error() !== false) {
161
+            $errors = array();
162
+            foreach(libxml_get_errors() as $error) {
163
+                $errors[] = sprintf('[%s #%d] Line %d: %s', $error->level == LIBXML_ERR_WARNING ? 'Warning' : ($error->level == LIBXML_ERR_ERROR ? 'Error' : 'Fatal'), $error->code, $error->line, $error->message);
164
+            }
165
+            libxml_clear_errors();
166
+            libxml_use_internal_errors($luie);
167
+            throw new \DOMException(
168
+                sprintf(
169
+                    'Error%s occurred while parsing the document: ' . "\n\n%s",
170
+                    count($errors) > 1 ? 's' : '',
171
+                    implode("\n", $errors)
172
+                )
173
+            );
174
+        }
175
+		
176
+        libxml_use_internal_errors($luie);
177
+		
178
+        $this->xpath = new \DOMXPath($this);
179
+		
180
+        if($this->isAgaviConfiguration()) {
181
+            XmlConfigParser::registerAgaviNamespaces($this);
182
+        }
183
+		
184
+        return $result;
185
+    }
186 186
 	
187
-	/**
188
-	 * Substitutes XIncludes in a DOMDocument object.
189
-	 *
190
-	 * @param      int $options Bitwise OR of the libxml option constants.
191
-	 *
192
-	 * @return     int The number of XIncludes in the document.
193
-	 *
194
-	 * @author     Noah Fontes <[email protected]>
195
-	 * @since      1.0.0
196
-	 */
197
-	public function xinclude($options = 0)
198
-	{
199
-		$luie = libxml_use_internal_errors(true);
200
-		libxml_clear_errors();
201
-		
202
-		$result = parent::xinclude($options);
203
-		
204
-		if(libxml_get_last_error() !== false) {
205
-			$throw = false;
206
-			$errors = array();
207
-			foreach(libxml_get_errors() as $error) {
208
-				if($error->level != LIBXML_ERR_WARNING) {
209
-					$throw = true;
210
-				}
211
-				$errors[] = sprintf('[%s #%d] Line %d: %s', $error->level == LIBXML_ERR_WARNING ? 'Warning' : ($error->level == LIBXML_ERR_ERROR ? 'Error' : 'Fatal'), $error->code, $error->line, $error->message);
212
-			}
213
-			libxml_clear_errors();
214
-			if($throw) {
215
-				libxml_use_internal_errors($luie);
216
-				throw new \DOMException(
217
-					sprintf(
218
-						'Error%s occurred while resolving XInclude directives: ' . "\n\n%s", 
219
-						count($errors) > 1 ? 's' : '', 
220
-						implode("\n", $errors)
221
-					)
222
-				);
223
-			}
224
-		}
225
-		
226
-		libxml_use_internal_errors($luie);
227
-		
228
-		return $result;
229
-	}
187
+    /**
188
+     * Substitutes XIncludes in a DOMDocument object.
189
+     *
190
+     * @param      int $options Bitwise OR of the libxml option constants.
191
+     *
192
+     * @return     int The number of XIncludes in the document.
193
+     *
194
+     * @author     Noah Fontes <[email protected]>
195
+     * @since      1.0.0
196
+     */
197
+    public function xinclude($options = 0)
198
+    {
199
+        $luie = libxml_use_internal_errors(true);
200
+        libxml_clear_errors();
201
+		
202
+        $result = parent::xinclude($options);
203
+		
204
+        if(libxml_get_last_error() !== false) {
205
+            $throw = false;
206
+            $errors = array();
207
+            foreach(libxml_get_errors() as $error) {
208
+                if($error->level != LIBXML_ERR_WARNING) {
209
+                    $throw = true;
210
+                }
211
+                $errors[] = sprintf('[%s #%d] Line %d: %s', $error->level == LIBXML_ERR_WARNING ? 'Warning' : ($error->level == LIBXML_ERR_ERROR ? 'Error' : 'Fatal'), $error->code, $error->line, $error->message);
212
+            }
213
+            libxml_clear_errors();
214
+            if($throw) {
215
+                libxml_use_internal_errors($luie);
216
+                throw new \DOMException(
217
+                    sprintf(
218
+                        'Error%s occurred while resolving XInclude directives: ' . "\n\n%s", 
219
+                        count($errors) > 1 ? 's' : '', 
220
+                        implode("\n", $errors)
221
+                    )
222
+                );
223
+            }
224
+        }
225
+		
226
+        libxml_use_internal_errors($luie);
227
+		
228
+        return $result;
229
+    }
230 230
 	
231
-	/**
232
-	 * Import a node into the current document.
233
-	 *
234
-	 * @param      \DOMNode $node The node to import.
235
-	 * @param      bool     $deep Whether or not to recursively import the node's
236
-	 *                            subtree.
237
-	 *
238
-	 * @return     \DOMNode|XmlConfigDomNode|bool  The copied node, or false if it cannot be copied.
239
-	 *
240
-	 * @author     Noah Fontes <[email protected]>
241
-	 * @since      1.0.0
242
-	 */
243
-	public function importNode(\DOMNode $node, $deep)
244
-	{
245
-		$luie = libxml_use_internal_errors(true);
246
-		libxml_clear_errors();
247
-		
248
-		$result = parent::importNode($node, $deep);
249
-		
250
-		if(libxml_get_last_error() !== false) {
251
-			$errors = array();
252
-			foreach(libxml_get_errors() as $error) {
253
-				$errors[] = sprintf('[%s #%d] Line %d: %s', $error->level == LIBXML_ERR_WARNING ? 'Warning' : ($error->level == LIBXML_ERR_ERROR ? 'Error' : 'Fatal'), $error->code, $error->line, $error->message);
254
-			}
255
-			libxml_clear_errors();
256
-			libxml_use_internal_errors($luie);
257
-			throw new \DOMException(
258
-				sprintf(
259
-					'Error%s occurred while importing a new node "%s": ' . "\n\n%s",
260
-					count($errors) > 1 ? 's' : '', 
261
-					$node->nodeName,
262
-					implode("\n", $errors)
263
-				)
264
-			);
265
-		}
266
-		
267
-		libxml_use_internal_errors($luie);
268
-		
269
-		return $result;
270
-	}
231
+    /**
232
+     * Import a node into the current document.
233
+     *
234
+     * @param      \DOMNode $node The node to import.
235
+     * @param      bool     $deep Whether or not to recursively import the node's
236
+     *                            subtree.
237
+     *
238
+     * @return     \DOMNode|XmlConfigDomNode|bool  The copied node, or false if it cannot be copied.
239
+     *
240
+     * @author     Noah Fontes <[email protected]>
241
+     * @since      1.0.0
242
+     */
243
+    public function importNode(\DOMNode $node, $deep)
244
+    {
245
+        $luie = libxml_use_internal_errors(true);
246
+        libxml_clear_errors();
247
+		
248
+        $result = parent::importNode($node, $deep);
249
+		
250
+        if(libxml_get_last_error() !== false) {
251
+            $errors = array();
252
+            foreach(libxml_get_errors() as $error) {
253
+                $errors[] = sprintf('[%s #%d] Line %d: %s', $error->level == LIBXML_ERR_WARNING ? 'Warning' : ($error->level == LIBXML_ERR_ERROR ? 'Error' : 'Fatal'), $error->code, $error->line, $error->message);
254
+            }
255
+            libxml_clear_errors();
256
+            libxml_use_internal_errors($luie);
257
+            throw new \DOMException(
258
+                sprintf(
259
+                    'Error%s occurred while importing a new node "%s": ' . "\n\n%s",
260
+                    count($errors) > 1 ? 's' : '', 
261
+                    $node->nodeName,
262
+                    implode("\n", $errors)
263
+                )
264
+            );
265
+        }
266
+		
267
+        libxml_use_internal_errors($luie);
268
+		
269
+        return $result;
270
+    }
271 271
 	
272
-	/**
273
-	 * Validate a document based on a schema.
274
-	 *
275
-	 * @param      string $filename The path to the schema.
276
-	 *
277
-	 * @return     bool True if the validation is successful; false otherwise.
278
-	 *
279
-	 * @author     Noah Fontes <[email protected]>
280
-	 * @since      1.0.0
281
-	 */
282
-	public function schemaValidate($filename)
283
-	{
284
-		$luie = libxml_use_internal_errors(true);
285
-		libxml_clear_errors();
286
-		
287
-		// gotta do the @ to suppress PHP warnings when the schema cannot be loaded or is invalid
288
-		if(!$result = @parent::schemaValidate($filename)) {
289
-			$errors = array();
290
-			foreach(libxml_get_errors() as $error) {
291
-				$errors[] = sprintf('[%s #%d] Line %d: %s', $error->level == LIBXML_ERR_WARNING ? 'Warning' : ($error->level == LIBXML_ERR_ERROR ? 'Error' : 'Fatal'), $error->code, $error->line, $error->message);
292
-			}
293
-			libxml_clear_errors();
294
-			libxml_use_internal_errors($luie);
295
-			throw new \DOMException(
296
-				sprintf(
297
-					'XML Schema validation with "%s" failed due to the following error%s: ' . "\n\n%s", 
298
-					$filename, 
299
-					count($errors) > 1 ? 's' : '', 
300
-					implode("\n", $errors)
301
-				)
302
-			);
303
-		}
304
-		
305
-		libxml_use_internal_errors($luie);
306
-		
307
-		return $result;
308
-	}
272
+    /**
273
+     * Validate a document based on a schema.
274
+     *
275
+     * @param      string $filename The path to the schema.
276
+     *
277
+     * @return     bool True if the validation is successful; false otherwise.
278
+     *
279
+     * @author     Noah Fontes <[email protected]>
280
+     * @since      1.0.0
281
+     */
282
+    public function schemaValidate($filename)
283
+    {
284
+        $luie = libxml_use_internal_errors(true);
285
+        libxml_clear_errors();
286
+		
287
+        // gotta do the @ to suppress PHP warnings when the schema cannot be loaded or is invalid
288
+        if(!$result = @parent::schemaValidate($filename)) {
289
+            $errors = array();
290
+            foreach(libxml_get_errors() as $error) {
291
+                $errors[] = sprintf('[%s #%d] Line %d: %s', $error->level == LIBXML_ERR_WARNING ? 'Warning' : ($error->level == LIBXML_ERR_ERROR ? 'Error' : 'Fatal'), $error->code, $error->line, $error->message);
292
+            }
293
+            libxml_clear_errors();
294
+            libxml_use_internal_errors($luie);
295
+            throw new \DOMException(
296
+                sprintf(
297
+                    'XML Schema validation with "%s" failed due to the following error%s: ' . "\n\n%s", 
298
+                    $filename, 
299
+                    count($errors) > 1 ? 's' : '', 
300
+                    implode("\n", $errors)
301
+                )
302
+            );
303
+        }
304
+		
305
+        libxml_use_internal_errors($luie);
306
+		
307
+        return $result;
308
+    }
309 309
 	
310
-	/**
311
-	 * Validate a document based on a schema.
312
-	 *
313
-	 * @param      string $source A string containing the schema.
314
-	 *
315
-	 * @return     bool True if the validation is successful; false otherwise.
316
-	 *
317
-	 * @author     Noah Fontes <[email protected]>
318
-	 * @since      1.0.0
319
-	 */
320
-	public function schemaValidateSource($source)
321
-	{
322
-		$luie = libxml_use_internal_errors(true);
323
-		libxml_clear_errors();
324
-		
325
-		// gotta do the @ to suppress PHP warnings when the schema cannot be loaded or is invalid
326
-		if(!$result = @parent::schemaValidateSource($source)) {
327
-			$errors = array();
328
-			foreach(libxml_get_errors() as $error) {
329
-				$errors[] = sprintf('[%s #%d] Line %d: %s', $error->level == LIBXML_ERR_WARNING ? 'Warning' : ($error->level == LIBXML_ERR_ERROR ? 'Error' : 'Fatal'), $error->code, $error->line, $error->message);
330
-			}
331
-			libxml_clear_errors();
332
-			libxml_use_internal_errors($luie);
333
-			throw new \DOMException(
334
-				sprintf(
335
-					'XML Schema validation failed due to the following error%s: ' . "\n\n%s", 
336
-					count($errors) > 1 ? 's' : '', 
337
-					implode("\n", $errors)
338
-				)
339
-			);
340
-		}
341
-		
342
-		libxml_use_internal_errors($luie);
343
-		
344
-		return $result;
345
-	}
310
+    /**
311
+     * Validate a document based on a schema.
312
+     *
313
+     * @param      string $source A string containing the schema.
314
+     *
315
+     * @return     bool True if the validation is successful; false otherwise.
316
+     *
317
+     * @author     Noah Fontes <[email protected]>
318
+     * @since      1.0.0
319
+     */
320
+    public function schemaValidateSource($source)
321
+    {
322
+        $luie = libxml_use_internal_errors(true);
323
+        libxml_clear_errors();
324
+		
325
+        // gotta do the @ to suppress PHP warnings when the schema cannot be loaded or is invalid
326
+        if(!$result = @parent::schemaValidateSource($source)) {
327
+            $errors = array();
328
+            foreach(libxml_get_errors() as $error) {
329
+                $errors[] = sprintf('[%s #%d] Line %d: %s', $error->level == LIBXML_ERR_WARNING ? 'Warning' : ($error->level == LIBXML_ERR_ERROR ? 'Error' : 'Fatal'), $error->code, $error->line, $error->message);
330
+            }
331
+            libxml_clear_errors();
332
+            libxml_use_internal_errors($luie);
333
+            throw new \DOMException(
334
+                sprintf(
335
+                    'XML Schema validation failed due to the following error%s: ' . "\n\n%s", 
336
+                    count($errors) > 1 ? 's' : '', 
337
+                    implode("\n", $errors)
338
+                )
339
+            );
340
+        }
341
+		
342
+        libxml_use_internal_errors($luie);
343
+		
344
+        return $result;
345
+    }
346 346
 	
347
-	/**
348
-	 * Perform RELAX NG validation on the document.
349
-	 *
350
-	 * @param      string $filename The path to the schema.
351
-	 *
352
-	 * @return     bool True if the validation is successful; false otherwise.
353
-	 *
354
-	 * @author     Noah Fontes <[email protected]>
355
-	 * @since      1.0.0
356
-	 */
357
-	public function relaxNGValidate($filename)
358
-	{
359
-		$luie = libxml_use_internal_errors(true);
360
-		libxml_clear_errors();
361
-		
362
-		// gotta do the @ to suppress PHP warnings when the schema cannot be loaded or is invalid
363
-		if(!$result = @parent::relaxNGValidate($filename)) {
364
-			$errors = array();
365
-			foreach(libxml_get_errors() as $error) {
366
-				$errors[] = sprintf('[%s #%d] Line %d: %s', $error->level == LIBXML_ERR_WARNING ? 'Warning' : ($error->level == LIBXML_ERR_ERROR ? 'Error' : 'Fatal'), $error->code, $error->line, $error->message);
367
-			}
368
-			libxml_clear_errors();
369
-			libxml_use_internal_errors($luie);
370
-			throw new \DOMException(
371
-				sprintf(
372
-					'RELAX NG validation with "%s" failed due to the following error%s: ' . "\n\n%s",
373
-					$filename,
374
-					count($errors) > 1 ? 's' : '', 
375
-					implode("\n", $errors)
376
-				)
377
-			);
378
-		}
379
-		
380
-		libxml_use_internal_errors($luie);
381
-		
382
-		return $result;
383
-	}
347
+    /**
348
+     * Perform RELAX NG validation on the document.
349
+     *
350
+     * @param      string $filename The path to the schema.
351
+     *
352
+     * @return     bool True if the validation is successful; false otherwise.
353
+     *
354
+     * @author     Noah Fontes <[email protected]>
355
+     * @since      1.0.0
356
+     */
357
+    public function relaxNGValidate($filename)
358
+    {
359
+        $luie = libxml_use_internal_errors(true);
360
+        libxml_clear_errors();
361
+		
362
+        // gotta do the @ to suppress PHP warnings when the schema cannot be loaded or is invalid
363
+        if(!$result = @parent::relaxNGValidate($filename)) {
364
+            $errors = array();
365
+            foreach(libxml_get_errors() as $error) {
366
+                $errors[] = sprintf('[%s #%d] Line %d: %s', $error->level == LIBXML_ERR_WARNING ? 'Warning' : ($error->level == LIBXML_ERR_ERROR ? 'Error' : 'Fatal'), $error->code, $error->line, $error->message);
367
+            }
368
+            libxml_clear_errors();
369
+            libxml_use_internal_errors($luie);
370
+            throw new \DOMException(
371
+                sprintf(
372
+                    'RELAX NG validation with "%s" failed due to the following error%s: ' . "\n\n%s",
373
+                    $filename,
374
+                    count($errors) > 1 ? 's' : '', 
375
+                    implode("\n", $errors)
376
+                )
377
+            );
378
+        }
379
+		
380
+        libxml_use_internal_errors($luie);
381
+		
382
+        return $result;
383
+    }
384 384
 	
385
-	/**
386
-	 * Retrieve the DOMXPath instance that is associated with this document.
387
-	 *
388
-	 * @return     \DOMXPath The DOMXPath instance.
389
-	 *
390
-	 * @author     David Zülke <[email protected]>
391
-	 * @since      1.0.0
392
-	 */
393
-	public function getXpath()
394
-	{
395
-		return $this->xpath;
396
-	}
385
+    /**
386
+     * Retrieve the DOMXPath instance that is associated with this document.
387
+     *
388
+     * @return     \DOMXPath The DOMXPath instance.
389
+     *
390
+     * @author     David Zülke <[email protected]>
391
+     * @since      1.0.0
392
+     */
393
+    public function getXpath()
394
+    {
395
+        return $this->xpath;
396
+    }
397 397
 	
398
-	/**
399
-	 * Set a default namespace that should be used when accessing elements via
400
-	 * convenience methods (such as magic get overload for children), and bind it
401
-	 * to the given prefix for use in XPath expressions.
402
-	 *
403
-	 * @param      string $namespaceUri A namespace URI
404
-	 * @param      string $prefix       An optional prefix, defaulting to "_default"
405
-	 *
406
-	 * @author     David Zülke <[email protected]>
407
-	 * @since      1.0.0
408
-	 */
409
-	public function setDefaultNamespace($namespaceUri, $prefix = '_default')
410
-	{
411
-		$this->defaultNamespaceUri = $namespaceUri;
412
-		$this->defaultNamespacePrefix = $prefix;
413
-		
414
-		$this->xpath->registerNamespace($prefix, $namespaceUri);
415
-	}
398
+    /**
399
+     * Set a default namespace that should be used when accessing elements via
400
+     * convenience methods (such as magic get overload for children), and bind it
401
+     * to the given prefix for use in XPath expressions.
402
+     *
403
+     * @param      string $namespaceUri A namespace URI
404
+     * @param      string $prefix       An optional prefix, defaulting to "_default"
405
+     *
406
+     * @author     David Zülke <[email protected]>
407
+     * @since      1.0.0
408
+     */
409
+    public function setDefaultNamespace($namespaceUri, $prefix = '_default')
410
+    {
411
+        $this->defaultNamespaceUri = $namespaceUri;
412
+        $this->defaultNamespacePrefix = $prefix;
413
+		
414
+        $this->xpath->registerNamespace($prefix, $namespaceUri);
415
+    }
416 416
 	
417
-	/**
418
-	 * Retrieve the default namespace URI that will be used by node classes, if
419
-	 * set, to conveniently retrieve child elements etc in some methods.
420
-	 *
421
-	 * @return     string A namespace URI.
422
-	 *
423
-	 * @author     David Zülke <[email protected]>
424
-	 * @since      1.0.0
425
-	 */
426
-	public function getDefaultNamespaceUri()
427
-	{
428
-		return $this->defaultNamespaceUri;
429
-	}
417
+    /**
418
+     * Retrieve the default namespace URI that will be used by node classes, if
419
+     * set, to conveniently retrieve child elements etc in some methods.
420
+     *
421
+     * @return     string A namespace URI.
422
+     *
423
+     * @author     David Zülke <[email protected]>
424
+     * @since      1.0.0
425
+     */
426
+    public function getDefaultNamespaceUri()
427
+    {
428
+        return $this->defaultNamespaceUri;
429
+    }
430 430
 	
431
-	/**
432
-	 * Retrieve the default namespace prefix that will be used by node classes, if
433
-	 * set, to conveniently retrieve child elements etc via XPath. 
434
-	 *
435
-	 * @return     string A namespace prefix.
436
-	 *
437
-	 * @author     David Zülke <[email protected]>
438
-	 * @since      1.0.0
439
-	 */
440
-	public function getDefaultNamespacePrefix()
441
-	{
442
-		return $this->defaultNamespacePrefix;
443
-	}
431
+    /**
432
+     * Retrieve the default namespace prefix that will be used by node classes, if
433
+     * set, to conveniently retrieve child elements etc via XPath. 
434
+     *
435
+     * @return     string A namespace prefix.
436
+     *
437
+     * @author     David Zülke <[email protected]>
438
+     * @since      1.0.0
439
+     */
440
+    public function getDefaultNamespacePrefix()
441
+    {
442
+        return $this->defaultNamespacePrefix;
443
+    }
444 444
 	
445
-	/**
446
-	 * Check whether or not this is a standard Agavi configuration file, i.e. with
447
-	 * a <configurations> and <configuration> envelope.
448
-	 *
449
-	 * @return     bool true, if it is an Agavi config structure, false otherwise.
450
-	 *
451
-	 * @author     David Zülke <[email protected]>
452
-	 * @since      1.0.0
453
-	 */
454
-	public function isAgaviConfiguration()
455
-	{
456
-		return XmlConfigParser::isAgaviConfigurationDocument($this);
457
-	}
445
+    /**
446
+     * Check whether or not this is a standard Agavi configuration file, i.e. with
447
+     * a <configurations> and <configuration> envelope.
448
+     *
449
+     * @return     bool true, if it is an Agavi config structure, false otherwise.
450
+     *
451
+     * @author     David Zülke <[email protected]>
452
+     * @since      1.0.0
453
+     */
454
+    public function isAgaviConfiguration()
455
+    {
456
+        return XmlConfigParser::isAgaviConfigurationDocument($this);
457
+    }
458 458
 	
459
-	/**
460
-	 * Retrieve the namespace of the Agavi envelope.
461
-	 *
462
-	 * @return     string A namespace URI, or null if it's not an Agavi config.
463
-	 *
464
-	 * @author     David Zülke <[email protected]>
465
-	 * @since      1.0.0
466
-	 */
467
-	public function getAgaviEnvelopeNamespace()
468
-	{
469
-		if($this->isAgaviConfiguration()) {
470
-			return $this->documentElement->namespaceURI;
471
-		}
472
-	}
459
+    /**
460
+     * Retrieve the namespace of the Agavi envelope.
461
+     *
462
+     * @return     string A namespace URI, or null if it's not an Agavi config.
463
+     *
464
+     * @author     David Zülke <[email protected]>
465
+     * @since      1.0.0
466
+     */
467
+    public function getAgaviEnvelopeNamespace()
468
+    {
469
+        if($this->isAgaviConfiguration()) {
470
+            return $this->documentElement->namespaceURI;
471
+        }
472
+    }
473 473
 	
474
-	/**
475
-	 * Method to retrieve a list of Agavi <configuration> elements regardless of
476
-	 * their namespace.
477
-	 *
478
-	 * @return     XmlConfigDomElement[] A list of XmlConfigDomElement elements.
479
-	 *
480
-	 * @author     David Zülke <[email protected]>
481
-	 * @since      1.0.0
482
-	 */
483
-	public function getConfigurationElements()
484
-	{
485
-		$retval = array();
486
-		
487
-		if($this->isAgaviConfiguration()) {
488
-			$agaviNs = $this->getAgaviEnvelopeNamespace();
474
+    /**
475
+     * Method to retrieve a list of Agavi <configuration> elements regardless of
476
+     * their namespace.
477
+     *
478
+     * @return     XmlConfigDomElement[] A list of XmlConfigDomElement elements.
479
+     *
480
+     * @author     David Zülke <[email protected]>
481
+     * @since      1.0.0
482
+     */
483
+    public function getConfigurationElements()
484
+    {
485
+        $retval = array();
486
+		
487
+        if($this->isAgaviConfiguration()) {
488
+            $agaviNs = $this->getAgaviEnvelopeNamespace();
489 489
 			
490
-			foreach($this->documentElement->childNodes as $node) {
491
-				if($node->nodeType == XML_ELEMENT_NODE && $node->localName == 'configuration' && $node->namespaceURI == $agaviNs) {
492
-					$retval[] = $node;
493
-				}
494
-			}
495
-		}
496
-		
497
-		return $retval;
498
-	}
490
+            foreach($this->documentElement->childNodes as $node) {
491
+                if($node->nodeType == XML_ELEMENT_NODE && $node->localName == 'configuration' && $node->namespaceURI == $agaviNs) {
492
+                    $retval[] = $node;
493
+                }
494
+            }
495
+        }
496
+		
497
+        return $retval;
498
+    }
499 499
 	
500
-	/**
501
-	 * Method to retrieve the Agavi <sandbox> element regardless of the namespace.
502
-	 *
503
-	 * @return     XmlConfigDomElement The <sandbox> element, or null.
504
-	 *
505
-	 * @author     David Zülke <[email protected]>
506
-	 * @since      1.0.0
507
-	 */
508
-	public function getSandbox()
509
-	{
510
-		if($this->isAgaviConfiguration()) {
511
-			$agaviNs = $this->getAgaviEnvelopeNamespace();
500
+    /**
501
+     * Method to retrieve the Agavi <sandbox> element regardless of the namespace.
502
+     *
503
+     * @return     XmlConfigDomElement The <sandbox> element, or null.
504
+     *
505
+     * @author     David Zülke <[email protected]>
506
+     * @since      1.0.0
507
+     */
508
+    public function getSandbox()
509
+    {
510
+        if($this->isAgaviConfiguration()) {
511
+            $agaviNs = $this->getAgaviEnvelopeNamespace();
512 512
 			
513
-			foreach($this->documentElement->childNodes as $node) {
514
-				if($node->nodeType == XML_ELEMENT_NODE && $node->localName == 'sandbox' && $node->namespaceURI == $agaviNs) {
515
-					return $node;
516
-				}
517
-			}
518
-		}
519
-	}
513
+            foreach($this->documentElement->childNodes as $node) {
514
+                if($node->nodeType == XML_ELEMENT_NODE && $node->localName == 'sandbox' && $node->namespaceURI == $agaviNs) {
515
+                    return $node;
516
+                }
517
+            }
518
+        }
519
+    }
520 520
 }
521 521
 
522 522
 ?>
523 523
\ No newline at end of file
Please login to merge, or discard this patch.
src/config/util/dom/XmlConfigDomElement.class.php 3 patches
Doc Comments   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 	 *                                  namespace will be used. If an empty string, no namespace
181 181
 	 *                                  will be used.
182 182
 	 *
183
-	 * @return     XmlConfigDomElement[] A list of the child elements.
183
+	 * @return     \DOMNodeList A list of the child elements.
184 184
 	 *
185 185
 	 * @author     David Zülke <[email protected]>
186 186
 	 * @since      1.0.0
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
 	 * @param      string $localName    An attribute name.
440 440
 	 * @param      mixed  $default      A default attribute value.
441 441
 	 *
442
-	 * @return     mixed An attribute value, if the attribute exists, otherwise
442
+	 * @return     string An attribute value, if the attribute exists, otherwise
443 443
 	 *                   null or the given default.
444 444
 	 *
445 445
 	 * @see        DOMElement::getAttributeNS()
@@ -474,6 +474,7 @@  discard block
 block discarded – undo
474 474
 	/**
475 475
 	 * Retrieve all attributes of the element that are in the given namespace.
476 476
 	 *
477
+	 * @param string $namespaceUri
477 478
 	 * @return     array An associative array of attribute names and values.
478 479
 	 *
479 480
 	 * @author     David Zülke <[email protected]>
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -111,8 +111,8 @@  discard block
 block discarded – undo
111 111
 		$preserveWhitespace = $this->getAttributeNS(XmlConfigParser::NAMESPACE_XML_1998, 'space') == 'preserve';
112 112
 		$literalize = Toolkit::literalize($this->getAttributeNS(XmlConfigParser::NAMESPACE_AGAVI_ENVELOPE_LATEST, 'literalize')) !== false;
113 113
 		
114
-		if($literalize) {
115
-			if($preserveWhitespace && ($trimmedValue === '' || $value != $trimmedValue)) {
114
+		if ($literalize) {
115
+			if ($preserveWhitespace && ($trimmedValue === '' || $value != $trimmedValue)) {
116 116
 				// we must preserve whitespace, and there is leading or trailing whitespace in the original value, so we won't run Toolkit::literalize(), which trims the input and then converts "true" to a boolean and so forth
117 117
 				// however, we should still expand possible occurrences of config directives
118 118
 				$value = Toolkit::expandDirectives($value);
@@ -120,9 +120,9 @@  discard block
 block discarded – undo
120 120
 				// no need to preserve whitespace, or no leading/trailing whitespace, which means we can expand "true", "false" and so forth using Toolkit::literalize()
121 121
 				$value = Toolkit::literalize($trimmedValue);
122 122
 			}
123
-		} elseif(!$preserveWhitespace) {
123
+		} elseif (!$preserveWhitespace) {
124 124
 			$value = $trimmedValue;
125
-			if($value === '') {
125
+			if ($value === '') {
126 126
 				// with or without literalize, an empty string must be converted to NULL if xml:space is default (see ticket #1203 and AEP-100)
127 127
 				$value = null;
128 128
 			}
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 	{
144 144
 		// should only pull elements from the default ns
145 145
 		$prefix = $this->ownerDocument->getDefaultNamespacePrefix();
146
-		if($prefix) {
146
+		if ($prefix) {
147 147
 			return $this->ownerDocument->getXpath()->query(sprintf('child::%s:*', $prefix), $this);
148 148
 		} else {
149 149
 			return $this->ownerDocument->getXpath()->query('child::*', $this);
@@ -242,16 +242,16 @@  discard block
 block discarded – undo
242 242
 		$marker = uniqid('', true);
243 243
 		$this->setAttributeNS(XmlConfigParser::NAMESPACE_AGAVI_ANNOTATIONS_LATEST, 'agavi_annotations_latest:marker', $marker);
244 244
 		
245
-		if($pluralMagic) {
245
+		if ($pluralMagic) {
246 246
 			// we always assume that we either get plural names, or the singular of the singular is not different from the singular :)
247 247
 			$singularName = $this->singularize($name);
248
-			if($namespaceUri) {
248
+			if ($namespaceUri) {
249 249
 				$query = 'count(child::*[local-name() = "%2$s" and namespace-uri() = "%3$s" and ../@agavi_annotations_latest:marker = "%4$s"]) + count(child::*[local-name() = "%1$s" and namespace-uri() = "%3$s" and ../@agavi_annotations_latest:marker = "%4$s"]/*[local-name() = "%2$s" and namespace-uri() = "%3$s" and ../../@agavi_annotations_latest:marker = "%4$s"])';
250 250
 			} else {
251 251
 				$query = 'count(%1$s[../@agavi_annotations_latest:marker = "%4$s"]/%2$s[../../@agavi_annotations_latest:marker = "%4$s"]) + count(%2$s[../@agavi_annotations_latest:marker = "%4$s"])';
252 252
 			}
253 253
 		} else {
254
-			if($namespaceUri) {
254
+			if ($namespaceUri) {
255 255
 				$query = 'count(child::*[local-name() = "%1$s" and namespace-uri() = "%3$s" and ../@agavi_annotations_latest:marker = "%4$s"])';
256 256
 			} else {
257 257
 				$query = 'count(%1$s[../@agavi_annotations_latest:marker = "%4$s"])';
@@ -318,16 +318,16 @@  discard block
 block discarded – undo
318 318
 		$marker = uniqid('', true);
319 319
 		$this->setAttributeNS(XmlConfigParser::NAMESPACE_AGAVI_ANNOTATIONS_LATEST, 'agavi_annotations_latest:marker', $marker);
320 320
 		
321
-		if($pluralMagic) {
321
+		if ($pluralMagic) {
322 322
 			// we always assume that we either get plural names, or the singular of the singular is not different from the singular :)
323 323
 			$singularName = $this->singularize($name);
324
-			if($namespaceUri) {
324
+			if ($namespaceUri) {
325 325
 				$query = 'child::*[local-name() = "%2$s" and namespace-uri() = "%3$s" and ../@agavi_annotations_latest:marker = "%4$s"] | child::*[local-name() = "%1$s" and namespace-uri() = "%3$s" and ../@agavi_annotations_latest:marker = "%4$s"]/*[local-name() = "%2$s" and namespace-uri() = "%3$s" and ../../@agavi_annotations_latest:marker = "%4$s"]';
326 326
 			} else {
327 327
 				$query = '%1$s[../@agavi_annotations_latest:marker = "%4$s"]/%2$s[../../@agavi_annotations_latest:marker = "%4$s"] | %2$s[../@agavi_annotations_latest:marker = "%4$s"]';
328 328
 			}
329 329
 		} else {
330
-			if($namespaceUri) {
330
+			if ($namespaceUri) {
331 331
 				$query = 'child::*[local-name() = "%1$s" and namespace-uri() = "%3$s" and ../@agavi_annotations_latest:marker = "%4$s"]';
332 332
 			} else {
333 333
 				$query = '%1$s[../@agavi_annotations_latest:marker = "%4$s"]';
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
 		$marker = uniqid('', true);
389 389
 		$this->setAttributeNS(XmlConfigParser::NAMESPACE_AGAVI_ANNOTATIONS_LATEST, 'agavi_annotations_latest:marker', $marker);
390 390
 		
391
-		if($namespaceUri) {
391
+		if ($namespaceUri) {
392 392
 			$query = 'self::node()[count(child::*[local-name() = "%1$s" and namespace-uri() = "%2$s" and ../@agavi_annotations_latest:marker = "%3$s"]) = 1]/*[local-name() = "%1$s" and namespace-uri() = "%2$s" and ../@agavi_annotations_latest:marker = "%3$s"]';
393 393
 		} else {
394 394
 			$query = 'self::node()[count(child::%1$s[../@agavi_annotations_latest:marker = "%3$s"]) = 1]/%1$s[../@agavi_annotations_latest:marker = "%3$s"]';
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
 		
424 424
 		// getAttribute returns '' when the attribute doesn't exist, but any
425 425
 		// null-ish value is probably unacceptable anyway
426
-		if($retval == null) {
426
+		if ($retval == null) {
427 427
 			$retval = $default;
428 428
 		}
429 429
 		
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
 	{
452 452
 		$retval = parent::getAttributeNS($namespaceUri, $localName);
453 453
 		
454
-		if($retval === null) {
454
+		if ($retval === null) {
455 455
 			$retval = $default;
456 456
 		}
457 457
 		
@@ -483,7 +483,7 @@  discard block
 block discarded – undo
483 483
 	{
484 484
 		$retval = array();
485 485
 		
486
-		foreach($this->ownerDocument->getXpath()->query(sprintf('@*[namespace-uri() = "%s"]', $namespaceUri), $this) as $attribute) {
486
+		foreach ($this->ownerDocument->getXpath()->query(sprintf('@*[namespace-uri() = "%s"]', $namespaceUri), $this) as $attribute) {
487 487
 			$retval[$attribute->localName] = $attribute->nodeValue;
488 488
 		}
489 489
 		
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
 	 */
501 501
 	public function hasAgaviParameters()
502 502
 	{
503
-		if($this->ownerDocument->isAgaviConfiguration()) {
503
+		if ($this->ownerDocument->isAgaviConfiguration()) {
504 504
 			return $this->has('parameters', XmlConfigParser::NAMESPACE_AGAVI_ENVELOPE_LATEST);
505 505
 		}
506 506
 		
@@ -524,19 +524,19 @@  discard block
 block discarded – undo
524 524
 		$result = $existing;
525 525
 		$offset = 0;
526 526
 		
527
-		if($this->ownerDocument->isAgaviConfiguration()) {
527
+		if ($this->ownerDocument->isAgaviConfiguration()) {
528 528
 			$elements = $this->get('parameters', XmlConfigParser::NAMESPACE_AGAVI_ENVELOPE_LATEST);
529 529
 
530 530
 			/** @var XmlConfigDomElement $element */
531
-			foreach($elements as $element) {
531
+			foreach ($elements as $element) {
532 532
 				$key = null;
533
-				if(!$element->hasAttribute('name')) {
533
+				if (!$element->hasAttribute('name')) {
534 534
 					$result[$key = $offset++] = null;
535 535
 				} else {
536 536
 					$key = $element->getAttribute('name');
537 537
 				}
538 538
 				
539
-				if($element->hasAgaviParameters()) {
539
+				if ($element->hasAgaviParameters()) {
540 540
 					$result[$key] = isset($result[$key]) && is_array($result[$key]) ? $result[$key] : array();
541 541
 					$result[$key] = $element->getAgaviParameters($result[$key]);
542 542
 				} else {
Please login to merge, or discard this patch.
Indentation   +463 added lines, -463 removed lines patch added patch discarded remove patch
@@ -36,517 +36,517 @@
 block discarded – undo
36 36
 class XmlConfigDomElement extends \DOMElement implements \IteratorAggregate
37 37
 {
38 38
 
39
-	/**
40
-	 * __toString() magic method, returns the element value.
41
-	 *
42
-	 * @see        AgaviXmlConfigDomElement::getValue()
43
-	 *
44
-	 * @return     string The element value.
45
-	 *
46
-	 * @author     David Zülke <[email protected]>
47
-	 * @since      1.0.0
48
-	 */
49
-	public function __toString()
50
-	{
51
-		return $this->getValue();
52
-	}
39
+    /**
40
+     * __toString() magic method, returns the element value.
41
+     *
42
+     * @see        AgaviXmlConfigDomElement::getValue()
43
+     *
44
+     * @return     string The element value.
45
+     *
46
+     * @author     David Zülke <[email protected]>
47
+     * @since      1.0.0
48
+     */
49
+    public function __toString()
50
+    {
51
+        return $this->getValue();
52
+    }
53 53
 	
54
-	/**
55
-	 * Returns the element name.
56
-	 *
57
-	 * @return     string The element name.
58
-	 *
59
-	 * @author     David Zülke <[email protected]>
60
-	 * @since      1.0.0
61
-	 */
62
-	public function getName()
63
-	{
64
-		// what to return here? name with prefix? no.
65
-		// but... element name, or with ns prefix?
66
-		return $this->nodeName;
67
-	}
54
+    /**
55
+     * Returns the element name.
56
+     *
57
+     * @return     string The element name.
58
+     *
59
+     * @author     David Zülke <[email protected]>
60
+     * @since      1.0.0
61
+     */
62
+    public function getName()
63
+    {
64
+        // what to return here? name with prefix? no.
65
+        // but... element name, or with ns prefix?
66
+        return $this->nodeName;
67
+    }
68 68
 	
69
-	/**
70
-	 * Returns the element value.
71
-	 *
72
-	 * @return     string The element value.
73
-	 *
74
-	 * @author     David Zülke <[email protected]>
75
-	 * @since      1.0.0
76
-	 */
77
-	public function getValue()
78
-	{
79
-		// TODO: or textContent?
80
-		// trimmed or not? in utf-8 or native encoding?
81
-		// I'd really say we only support utf-8 for the new api
82
-		return $this->nodeValue;
83
-	}
69
+    /**
70
+     * Returns the element value.
71
+     *
72
+     * @return     string The element value.
73
+     *
74
+     * @author     David Zülke <[email protected]>
75
+     * @since      1.0.0
76
+     */
77
+    public function getValue()
78
+    {
79
+        // TODO: or textContent?
80
+        // trimmed or not? in utf-8 or native encoding?
81
+        // I'd really say we only support utf-8 for the new api
82
+        return $this->nodeValue;
83
+    }
84 84
 	
85
-	/**
86
-	 * Returns the literal value. By default, that means whitespace is trimmed,
87
-	 * boolean literals ("on", "yes", "true", "no", "off", "false") are converted
88
-	 * and configuration directives ("%core.app_dir%") are expanded.
89
-	 *
90
-	 * Takes attributes {http://www.w3.org/XML/1998/namespace}space and
91
-	 * {http://agavi.org/agavi/config/global/envelope/1.1}literalize into account
92
-	 * when computing the literal value. This way, users can control the trimming
93
-	 * and the literalization of values.
94
-	 * 
95
-	 * AEP-100 has a list of all the conversion rules that apply.
96
-	 *
97
-	 * @return     mixed The element content converted according to the rules
98
-	 *                   defined in AEP-100.
99
-	 *
100
-	 * @author     David Zülke <[email protected]>
101
-	 * @since      1.1.0
102
-	 */
103
-	public function getLiteralValue()
104
-	{
105
-		$value = $this->getValue();
106
-		// XML specifies [\x9\xA\xD\x20] as whitespace
107
-		// trim strips more than that
108
-		// no problem though, because these other chars aren't legal in XML
109
-		$trimmedValue = trim($value);
85
+    /**
86
+     * Returns the literal value. By default, that means whitespace is trimmed,
87
+     * boolean literals ("on", "yes", "true", "no", "off", "false") are converted
88
+     * and configuration directives ("%core.app_dir%") are expanded.
89
+     *
90
+     * Takes attributes {http://www.w3.org/XML/1998/namespace}space and
91
+     * {http://agavi.org/agavi/config/global/envelope/1.1}literalize into account
92
+     * when computing the literal value. This way, users can control the trimming
93
+     * and the literalization of values.
94
+     * 
95
+     * AEP-100 has a list of all the conversion rules that apply.
96
+     *
97
+     * @return     mixed The element content converted according to the rules
98
+     *                   defined in AEP-100.
99
+     *
100
+     * @author     David Zülke <[email protected]>
101
+     * @since      1.1.0
102
+     */
103
+    public function getLiteralValue()
104
+    {
105
+        $value = $this->getValue();
106
+        // XML specifies [\x9\xA\xD\x20] as whitespace
107
+        // trim strips more than that
108
+        // no problem though, because these other chars aren't legal in XML
109
+        $trimmedValue = trim($value);
110 110
 		
111
-		$preserveWhitespace = $this->getAttributeNS(XmlConfigParser::NAMESPACE_XML_1998, 'space') == 'preserve';
112
-		$literalize = Toolkit::literalize($this->getAttributeNS(XmlConfigParser::NAMESPACE_AGAVI_ENVELOPE_LATEST, 'literalize')) !== false;
111
+        $preserveWhitespace = $this->getAttributeNS(XmlConfigParser::NAMESPACE_XML_1998, 'space') == 'preserve';
112
+        $literalize = Toolkit::literalize($this->getAttributeNS(XmlConfigParser::NAMESPACE_AGAVI_ENVELOPE_LATEST, 'literalize')) !== false;
113 113
 		
114
-		if($literalize) {
115
-			if($preserveWhitespace && ($trimmedValue === '' || $value != $trimmedValue)) {
116
-				// we must preserve whitespace, and there is leading or trailing whitespace in the original value, so we won't run Toolkit::literalize(), which trims the input and then converts "true" to a boolean and so forth
117
-				// however, we should still expand possible occurrences of config directives
118
-				$value = Toolkit::expandDirectives($value);
119
-			} else {
120
-				// no need to preserve whitespace, or no leading/trailing whitespace, which means we can expand "true", "false" and so forth using Toolkit::literalize()
121
-				$value = Toolkit::literalize($trimmedValue);
122
-			}
123
-		} elseif(!$preserveWhitespace) {
124
-			$value = $trimmedValue;
125
-			if($value === '') {
126
-				// with or without literalize, an empty string must be converted to NULL if xml:space is default (see ticket #1203 and AEP-100)
127
-				$value = null;
128
-			}
129
-		}
114
+        if($literalize) {
115
+            if($preserveWhitespace && ($trimmedValue === '' || $value != $trimmedValue)) {
116
+                // we must preserve whitespace, and there is leading or trailing whitespace in the original value, so we won't run Toolkit::literalize(), which trims the input and then converts "true" to a boolean and so forth
117
+                // however, we should still expand possible occurrences of config directives
118
+                $value = Toolkit::expandDirectives($value);
119
+            } else {
120
+                // no need to preserve whitespace, or no leading/trailing whitespace, which means we can expand "true", "false" and so forth using Toolkit::literalize()
121
+                $value = Toolkit::literalize($trimmedValue);
122
+            }
123
+        } elseif(!$preserveWhitespace) {
124
+            $value = $trimmedValue;
125
+            if($value === '') {
126
+                // with or without literalize, an empty string must be converted to NULL if xml:space is default (see ticket #1203 and AEP-100)
127
+                $value = null;
128
+            }
129
+        }
130 130
 		
131
-		return $value;
132
-	}
131
+        return $value;
132
+    }
133 133
 	
134
-	/**
135
-	 * Returns an iterator for the child nodes.
136
-	 *
137
-	 * @return     \Iterator An iterator.
138
-	 *
139
-	 * @author     David Zülke <[email protected]>
140
-	 * @since      1.0.0
141
-	 */
142
-	public function getIterator()
143
-	{
144
-		// should only pull elements from the default ns
145
-		$prefix = $this->ownerDocument->getDefaultNamespacePrefix();
146
-		if($prefix) {
147
-			return $this->ownerDocument->getXpath()->query(sprintf('child::%s:*', $prefix), $this);
148
-		} else {
149
-			return $this->ownerDocument->getXpath()->query('child::*', $this);
150
-		}
151
-	}
134
+    /**
135
+     * Returns an iterator for the child nodes.
136
+     *
137
+     * @return     \Iterator An iterator.
138
+     *
139
+     * @author     David Zülke <[email protected]>
140
+     * @since      1.0.0
141
+     */
142
+    public function getIterator()
143
+    {
144
+        // should only pull elements from the default ns
145
+        $prefix = $this->ownerDocument->getDefaultNamespacePrefix();
146
+        if($prefix) {
147
+            return $this->ownerDocument->getXpath()->query(sprintf('child::%s:*', $prefix), $this);
148
+        } else {
149
+            return $this->ownerDocument->getXpath()->query('child::*', $this);
150
+        }
151
+    }
152 152
 	
153
-	/**
154
-	 * Retrieve singular form of given element name.
155
-	 * This does special splitting only of the last part of the name if the name
156
-	 * of the element contains hyphens, underscores or dots.
157
-	 *
158
-	 * @param      string $name The element name to singularize.
159
-	 *
160
-	 * @return     string The singularized element name.
161
-	 *
162
-	 * @author     Noah Fontes <[email protected]>
163
-	 * @since      1.0.0
164
-	 */
165
-	protected function singularize($name)
166
-	{
167
-		// TODO: shouldn't this be static?
168
-		$names = preg_split('#([_\-\.])#', $name, -1, PREG_SPLIT_DELIM_CAPTURE);
169
-		$names[count($names) - 1] = Inflector::singularize(end($names));
170
-		return implode('', $names);
171
-	}
153
+    /**
154
+     * Retrieve singular form of given element name.
155
+     * This does special splitting only of the last part of the name if the name
156
+     * of the element contains hyphens, underscores or dots.
157
+     *
158
+     * @param      string $name The element name to singularize.
159
+     *
160
+     * @return     string The singularized element name.
161
+     *
162
+     * @author     Noah Fontes <[email protected]>
163
+     * @since      1.0.0
164
+     */
165
+    protected function singularize($name)
166
+    {
167
+        // TODO: shouldn't this be static?
168
+        $names = preg_split('#([_\-\.])#', $name, -1, PREG_SPLIT_DELIM_CAPTURE);
169
+        $names[count($names) - 1] = Inflector::singularize(end($names));
170
+        return implode('', $names);
171
+    }
172 172
 	
173
-	/**
174
-	 * Convenience method to retrieve child elements of the given name.
175
-	 * Accepts singular or plural forms of the name, and will detect and handle
176
-	 * parent containers with plural names properly.
177
-	 *
178
-	 * @param      string $name         The name of the element(s) to check for.
179
-	 * @param      string $namespaceUri The namespace URI. If null, the document default
180
-	 *                                  namespace will be used. If an empty string, no namespace
181
-	 *                                  will be used.
182
-	 *
183
-	 * @return     XmlConfigDomElement[] A list of the child elements.
184
-	 *
185
-	 * @author     David Zülke <[email protected]>
186
-	 * @since      1.0.0
187
-	 */
188
-	public function get($name, $namespaceUri = null)
189
-	{
190
-		return $this->getChildren($name, $namespaceUri, true);
191
-	}
173
+    /**
174
+     * Convenience method to retrieve child elements of the given name.
175
+     * Accepts singular or plural forms of the name, and will detect and handle
176
+     * parent containers with plural names properly.
177
+     *
178
+     * @param      string $name         The name of the element(s) to check for.
179
+     * @param      string $namespaceUri The namespace URI. If null, the document default
180
+     *                                  namespace will be used. If an empty string, no namespace
181
+     *                                  will be used.
182
+     *
183
+     * @return     XmlConfigDomElement[] A list of the child elements.
184
+     *
185
+     * @author     David Zülke <[email protected]>
186
+     * @since      1.0.0
187
+     */
188
+    public function get($name, $namespaceUri = null)
189
+    {
190
+        return $this->getChildren($name, $namespaceUri, true);
191
+    }
192 192
 	
193
-	/**
194
-	 * Convenience method to check if there are child elements of the given name.
195
-	 * Accepts singular or plural forms of the name, and will detect and handle
196
-	 * parent containers with plural names properly.
197
-	 *
198
-	 * @param      string $name         The name of the element(s) to check for.
199
-	 * @param      string $namespaceUri The namespace URI. If null, the document default
200
-	 *                                  namespace will be used. If an empty string, no namespace
201
-	 *                                  will be used.
202
-	 *
203
-	 * @return     bool True if one or more child elements with the given name
204
-	 *                  exist, false otherwise.
205
-	 *
206
-	 * @author     David Zülke <[email protected]>
207
-	 * @since      1.0.0
208
-	 */
209
-	public function has($name, $namespaceUri = null)
210
-	{
211
-		return $this->hasChildren($name, $namespaceUri, true);
212
-	}
193
+    /**
194
+     * Convenience method to check if there are child elements of the given name.
195
+     * Accepts singular or plural forms of the name, and will detect and handle
196
+     * parent containers with plural names properly.
197
+     *
198
+     * @param      string $name         The name of the element(s) to check for.
199
+     * @param      string $namespaceUri The namespace URI. If null, the document default
200
+     *                                  namespace will be used. If an empty string, no namespace
201
+     *                                  will be used.
202
+     *
203
+     * @return     bool True if one or more child elements with the given name
204
+     *                  exist, false otherwise.
205
+     *
206
+     * @author     David Zülke <[email protected]>
207
+     * @since      1.0.0
208
+     */
209
+    public function has($name, $namespaceUri = null)
210
+    {
211
+        return $this->hasChildren($name, $namespaceUri, true);
212
+    }
213 213
 	
214
-	/**
215
-	 * Count the number of child elements with a given name.
216
-	 *
217
-	 * @param      string $name         The name of the element.
218
-	 * @param      string $namespaceUri The namespace URI. If null, the document default
219
-	 *                                  namespace will be used. If an empty string, no namespace
220
-	 *                                  will be used.
221
-	 * @param      bool   $pluralMagic  Whether or not to apply automatic singular/plural
222
-	 *                                  handling that skips plural container elements.
223
-	 *
224
-	 * @return     int The number of child elements with the given name.
225
-	 *
226
-	 * @author     Noah Fontes <[email protected]>
227
-	 * @author     David Zülke <[email protected]>
228
-	 * @since      1.0.0
229
-	 */
230
-	public function countChildren($name, $namespaceUri = null, $pluralMagic = false)
231
-	{
232
-		// if arg is null, then only check for elements from our default namespace
233
-		// if namespace uri is null, use default ns. if empty string, use no ns
234
-		$namespaceUri = ($namespaceUri === null ? $this->ownerDocument->getDefaultNamespaceUri() : $namespaceUri);
214
+    /**
215
+     * Count the number of child elements with a given name.
216
+     *
217
+     * @param      string $name         The name of the element.
218
+     * @param      string $namespaceUri The namespace URI. If null, the document default
219
+     *                                  namespace will be used. If an empty string, no namespace
220
+     *                                  will be used.
221
+     * @param      bool   $pluralMagic  Whether or not to apply automatic singular/plural
222
+     *                                  handling that skips plural container elements.
223
+     *
224
+     * @return     int The number of child elements with the given name.
225
+     *
226
+     * @author     Noah Fontes <[email protected]>
227
+     * @author     David Zülke <[email protected]>
228
+     * @since      1.0.0
229
+     */
230
+    public function countChildren($name, $namespaceUri = null, $pluralMagic = false)
231
+    {
232
+        // if arg is null, then only check for elements from our default namespace
233
+        // if namespace uri is null, use default ns. if empty string, use no ns
234
+        $namespaceUri = ($namespaceUri === null ? $this->ownerDocument->getDefaultNamespaceUri() : $namespaceUri);
235 235
 		
236
-		// init our vars
237
-		$query = '';
238
-		$singularName = null;
236
+        // init our vars
237
+        $query = '';
238
+        $singularName = null;
239 239
 		
240
-		// tag our element, because older libxmls will mess things up otherwise
241
-		// http://trac.agavi.org/ticket/1039
242
-		$marker = uniqid('', true);
243
-		$this->setAttributeNS(XmlConfigParser::NAMESPACE_AGAVI_ANNOTATIONS_LATEST, 'agavi_annotations_latest:marker', $marker);
240
+        // tag our element, because older libxmls will mess things up otherwise
241
+        // http://trac.agavi.org/ticket/1039
242
+        $marker = uniqid('', true);
243
+        $this->setAttributeNS(XmlConfigParser::NAMESPACE_AGAVI_ANNOTATIONS_LATEST, 'agavi_annotations_latest:marker', $marker);
244 244
 		
245
-		if($pluralMagic) {
246
-			// we always assume that we either get plural names, or the singular of the singular is not different from the singular :)
247
-			$singularName = $this->singularize($name);
248
-			if($namespaceUri) {
249
-				$query = 'count(child::*[local-name() = "%2$s" and namespace-uri() = "%3$s" and ../@agavi_annotations_latest:marker = "%4$s"]) + count(child::*[local-name() = "%1$s" and namespace-uri() = "%3$s" and ../@agavi_annotations_latest:marker = "%4$s"]/*[local-name() = "%2$s" and namespace-uri() = "%3$s" and ../../@agavi_annotations_latest:marker = "%4$s"])';
250
-			} else {
251
-				$query = 'count(%1$s[../@agavi_annotations_latest:marker = "%4$s"]/%2$s[../../@agavi_annotations_latest:marker = "%4$s"]) + count(%2$s[../@agavi_annotations_latest:marker = "%4$s"])';
252
-			}
253
-		} else {
254
-			if($namespaceUri) {
255
-				$query = 'count(child::*[local-name() = "%1$s" and namespace-uri() = "%3$s" and ../@agavi_annotations_latest:marker = "%4$s"])';
256
-			} else {
257
-				$query = 'count(%1$s[../@agavi_annotations_latest:marker = "%4$s"])';
258
-			}
259
-		}
245
+        if($pluralMagic) {
246
+            // we always assume that we either get plural names, or the singular of the singular is not different from the singular :)
247
+            $singularName = $this->singularize($name);
248
+            if($namespaceUri) {
249
+                $query = 'count(child::*[local-name() = "%2$s" and namespace-uri() = "%3$s" and ../@agavi_annotations_latest:marker = "%4$s"]) + count(child::*[local-name() = "%1$s" and namespace-uri() = "%3$s" and ../@agavi_annotations_latest:marker = "%4$s"]/*[local-name() = "%2$s" and namespace-uri() = "%3$s" and ../../@agavi_annotations_latest:marker = "%4$s"])';
250
+            } else {
251
+                $query = 'count(%1$s[../@agavi_annotations_latest:marker = "%4$s"]/%2$s[../../@agavi_annotations_latest:marker = "%4$s"]) + count(%2$s[../@agavi_annotations_latest:marker = "%4$s"])';
252
+            }
253
+        } else {
254
+            if($namespaceUri) {
255
+                $query = 'count(child::*[local-name() = "%1$s" and namespace-uri() = "%3$s" and ../@agavi_annotations_latest:marker = "%4$s"])';
256
+            } else {
257
+                $query = 'count(%1$s[../@agavi_annotations_latest:marker = "%4$s"])';
258
+            }
259
+        }
260 260
 		
261
-		$retval = (int)$this->ownerDocument->getXpath()->evaluate(sprintf($query, $name, $singularName, $namespaceUri, $marker), $this);
261
+        $retval = (int)$this->ownerDocument->getXpath()->evaluate(sprintf($query, $name, $singularName, $namespaceUri, $marker), $this);
262 262
 		
263
-		$this->removeAttributeNS(XmlConfigParser::NAMESPACE_AGAVI_ANNOTATIONS_LATEST, 'agavi_annotations_latest:marker');
263
+        $this->removeAttributeNS(XmlConfigParser::NAMESPACE_AGAVI_ANNOTATIONS_LATEST, 'agavi_annotations_latest:marker');
264 264
 		
265
-		return $retval;
266
-	}
265
+        return $retval;
266
+    }
267 267
 	
268
-	/**
269
-	 * Determine whether there is at least one instance of a child element with a
270
-	 * given name.
271
-	 *
272
-	 * @param      string $name         The name of the element.
273
-	 * @param      string $namespaceUri The namespace URI. If null, the document default
274
-	 *                                  namespace will be used. If an empty string, no namespace
275
-	 *                                  will be used.
276
-	 * @param      bool   $pluralMagic  Whether or not to apply automatic singular/plural
277
-	 *                                  handling that skips plural container elements.
278
-	 *
279
-	 * @return     bool True if one or more child elements with the given name
280
-	 *                  exist, false otherwise.
281
-	 *
282
-	 * @author     Noah Fontes <[email protected]>
283
-	 * @author     David Zülke <[email protected]>
284
-	 * @since      1.0.0
285
-	 */
286
-	public function hasChildren($name, $namespaceUri = null, $pluralMagic = false)
287
-	{
288
-		return $this->countChildren($name, $namespaceUri, $pluralMagic) !== 0;
289
-	}
268
+    /**
269
+     * Determine whether there is at least one instance of a child element with a
270
+     * given name.
271
+     *
272
+     * @param      string $name         The name of the element.
273
+     * @param      string $namespaceUri The namespace URI. If null, the document default
274
+     *                                  namespace will be used. If an empty string, no namespace
275
+     *                                  will be used.
276
+     * @param      bool   $pluralMagic  Whether or not to apply automatic singular/plural
277
+     *                                  handling that skips plural container elements.
278
+     *
279
+     * @return     bool True if one or more child elements with the given name
280
+     *                  exist, false otherwise.
281
+     *
282
+     * @author     Noah Fontes <[email protected]>
283
+     * @author     David Zülke <[email protected]>
284
+     * @since      1.0.0
285
+     */
286
+    public function hasChildren($name, $namespaceUri = null, $pluralMagic = false)
287
+    {
288
+        return $this->countChildren($name, $namespaceUri, $pluralMagic) !== 0;
289
+    }
290 290
 	
291
-	/**
292
-	 * Retrieve all children with the given element name.
293
-	 *
294
-	 * @param      string $name         The name of the element.
295
-	 * @param      string $namespaceUri The namespace URI. If null, the document default
296
-	 *                                  namespace will be used. If an empty string, no namespace
297
-	 *                                  will be used.
298
-	 * @param      bool   $pluralMagic  Whether or not to apply automatic singular/plural
299
-	 *                                  handling that skips plural container elements.
300
-	 *
301
-	 * @return     \DOMNodeList A list of the child elements.
302
-	 *
303
-	 * @author     Noah Fontes <[email protected]>
304
-	 * @author     David Zülke <[email protected]>
305
-	 * @since      1.0.0
306
-	 */
307
-	public function getChildren($name, $namespaceUri = null, $pluralMagic = false)
308
-	{
309
-		// if arg is null, then only check for elements from our default namespace
310
-		// if namespace uri is null, use default ns. if empty string, use no ns
311
-		$namespaceUri = ($namespaceUri === null ? $this->ownerDocument->getDefaultNamespaceUri() : $namespaceUri);
291
+    /**
292
+     * Retrieve all children with the given element name.
293
+     *
294
+     * @param      string $name         The name of the element.
295
+     * @param      string $namespaceUri The namespace URI. If null, the document default
296
+     *                                  namespace will be used. If an empty string, no namespace
297
+     *                                  will be used.
298
+     * @param      bool   $pluralMagic  Whether or not to apply automatic singular/plural
299
+     *                                  handling that skips plural container elements.
300
+     *
301
+     * @return     \DOMNodeList A list of the child elements.
302
+     *
303
+     * @author     Noah Fontes <[email protected]>
304
+     * @author     David Zülke <[email protected]>
305
+     * @since      1.0.0
306
+     */
307
+    public function getChildren($name, $namespaceUri = null, $pluralMagic = false)
308
+    {
309
+        // if arg is null, then only check for elements from our default namespace
310
+        // if namespace uri is null, use default ns. if empty string, use no ns
311
+        $namespaceUri = ($namespaceUri === null ? $this->ownerDocument->getDefaultNamespaceUri() : $namespaceUri);
312 312
 		
313
-		// init our vars
314
-		$query = '';
315
-		$singularName = null;
313
+        // init our vars
314
+        $query = '';
315
+        $singularName = null;
316 316
 		
317
-		// tag our element, because libxml will mess things up otherwise
318
-		$marker = uniqid('', true);
319
-		$this->setAttributeNS(XmlConfigParser::NAMESPACE_AGAVI_ANNOTATIONS_LATEST, 'agavi_annotations_latest:marker', $marker);
317
+        // tag our element, because libxml will mess things up otherwise
318
+        $marker = uniqid('', true);
319
+        $this->setAttributeNS(XmlConfigParser::NAMESPACE_AGAVI_ANNOTATIONS_LATEST, 'agavi_annotations_latest:marker', $marker);
320 320
 		
321
-		if($pluralMagic) {
322
-			// we always assume that we either get plural names, or the singular of the singular is not different from the singular :)
323
-			$singularName = $this->singularize($name);
324
-			if($namespaceUri) {
325
-				$query = 'child::*[local-name() = "%2$s" and namespace-uri() = "%3$s" and ../@agavi_annotations_latest:marker = "%4$s"] | child::*[local-name() = "%1$s" and namespace-uri() = "%3$s" and ../@agavi_annotations_latest:marker = "%4$s"]/*[local-name() = "%2$s" and namespace-uri() = "%3$s" and ../../@agavi_annotations_latest:marker = "%4$s"]';
326
-			} else {
327
-				$query = '%1$s[../@agavi_annotations_latest:marker = "%4$s"]/%2$s[../../@agavi_annotations_latest:marker = "%4$s"] | %2$s[../@agavi_annotations_latest:marker = "%4$s"]';
328
-			}
329
-		} else {
330
-			if($namespaceUri) {
331
-				$query = 'child::*[local-name() = "%1$s" and namespace-uri() = "%3$s" and ../@agavi_annotations_latest:marker = "%4$s"]';
332
-			} else {
333
-				$query = '%1$s[../@agavi_annotations_latest:marker = "%4$s"]';
334
-			}
335
-		}
336
-		/** @var \DOMXPath $xpath */
337
-		$xpath = $this->ownerDocument->getXpath();
338
-		$retval = $xpath->query(sprintf($query, $name, $singularName, $namespaceUri, $marker), $this);
321
+        if($pluralMagic) {
322
+            // we always assume that we either get plural names, or the singular of the singular is not different from the singular :)
323
+            $singularName = $this->singularize($name);
324
+            if($namespaceUri) {
325
+                $query = 'child::*[local-name() = "%2$s" and namespace-uri() = "%3$s" and ../@agavi_annotations_latest:marker = "%4$s"] | child::*[local-name() = "%1$s" and namespace-uri() = "%3$s" and ../@agavi_annotations_latest:marker = "%4$s"]/*[local-name() = "%2$s" and namespace-uri() = "%3$s" and ../../@agavi_annotations_latest:marker = "%4$s"]';
326
+            } else {
327
+                $query = '%1$s[../@agavi_annotations_latest:marker = "%4$s"]/%2$s[../../@agavi_annotations_latest:marker = "%4$s"] | %2$s[../@agavi_annotations_latest:marker = "%4$s"]';
328
+            }
329
+        } else {
330
+            if($namespaceUri) {
331
+                $query = 'child::*[local-name() = "%1$s" and namespace-uri() = "%3$s" and ../@agavi_annotations_latest:marker = "%4$s"]';
332
+            } else {
333
+                $query = '%1$s[../@agavi_annotations_latest:marker = "%4$s"]';
334
+            }
335
+        }
336
+        /** @var \DOMXPath $xpath */
337
+        $xpath = $this->ownerDocument->getXpath();
338
+        $retval = $xpath->query(sprintf($query, $name, $singularName, $namespaceUri, $marker), $this);
339 339
 		
340
-		$this->removeAttributeNS(XmlConfigParser::NAMESPACE_AGAVI_ANNOTATIONS_LATEST, 'agavi_annotations_latest:marker');
340
+        $this->removeAttributeNS(XmlConfigParser::NAMESPACE_AGAVI_ANNOTATIONS_LATEST, 'agavi_annotations_latest:marker');
341 341
 		
342
-		return $retval;
343
-	}
342
+        return $retval;
343
+    }
344 344
 	
345
-	/**
346
-	 * Determine whether this element has a particular child element. This method
347
-	 * succeeds only when there is exactly one child element with the given name.
348
-	 *
349
-	 * @param      string $name         The name of the element.
350
-	 * @param      string $namespaceUri The namespace URI. If null, the document default
351
-	 *                                  namespace will be used. If an empty string, no namespace
352
-	 *                                  will be used.
353
-	 *
354
-	 * @return     bool True if there is exactly one instance of an element with
355
-	 *                  the given name; false otherwise.
356
-	 *
357
-	 * @author     Noah Fontes <[email protected]>
358
-	 * @author     David Zülke <[email protected]>
359
-	 * @since      1.0.0
360
-	 */
361
-	public function hasChild($name, $namespaceUri = null)
362
-	{
363
-		return $this->getChild($name, $namespaceUri) !== null;
364
-	}
345
+    /**
346
+     * Determine whether this element has a particular child element. This method
347
+     * succeeds only when there is exactly one child element with the given name.
348
+     *
349
+     * @param      string $name         The name of the element.
350
+     * @param      string $namespaceUri The namespace URI. If null, the document default
351
+     *                                  namespace will be used. If an empty string, no namespace
352
+     *                                  will be used.
353
+     *
354
+     * @return     bool True if there is exactly one instance of an element with
355
+     *                  the given name; false otherwise.
356
+     *
357
+     * @author     Noah Fontes <[email protected]>
358
+     * @author     David Zülke <[email protected]>
359
+     * @since      1.0.0
360
+     */
361
+    public function hasChild($name, $namespaceUri = null)
362
+    {
363
+        return $this->getChild($name, $namespaceUri) !== null;
364
+    }
365 365
 	
366
-	/**
367
-	 * Return a single child element with a given name.
368
-	 * Only returns anything if there is exactly one child of this name.
369
-	 *
370
-	 * @param      string $name         The name of the element.
371
-	 * @param      string $namespaceUri The namespace URI. If null, the document default
372
-	 *                                  namespace will be used. If an empty string, no namespace
373
-	 *                                  will be used.
374
-	 *
375
-	 * @return     \DOMElement The child element, or null if none exists.
376
-	 *
377
-	 * @author     Noah Fontes <[email protected]>
378
-	 * @author     David Zülke <[email protected]>
379
-	 * @since      1.0.0
380
-	 */
381
-	public function getChild($name, $namespaceUri = null)
382
-	{
383
-		// if arg is null, then only check for elements from our default namespace
384
-		// if namespace uri is null, use default ns. if empty string, use no ns
385
-		$namespaceUri = ($namespaceUri === null ? $this->ownerDocument->getDefaultNamespaceUri() : $namespaceUri);
366
+    /**
367
+     * Return a single child element with a given name.
368
+     * Only returns anything if there is exactly one child of this name.
369
+     *
370
+     * @param      string $name         The name of the element.
371
+     * @param      string $namespaceUri The namespace URI. If null, the document default
372
+     *                                  namespace will be used. If an empty string, no namespace
373
+     *                                  will be used.
374
+     *
375
+     * @return     \DOMElement The child element, or null if none exists.
376
+     *
377
+     * @author     Noah Fontes <[email protected]>
378
+     * @author     David Zülke <[email protected]>
379
+     * @since      1.0.0
380
+     */
381
+    public function getChild($name, $namespaceUri = null)
382
+    {
383
+        // if arg is null, then only check for elements from our default namespace
384
+        // if namespace uri is null, use default ns. if empty string, use no ns
385
+        $namespaceUri = ($namespaceUri === null ? $this->ownerDocument->getDefaultNamespaceUri() : $namespaceUri);
386 386
 		
387
-		// tag our element, because libxml will mess things up otherwise
388
-		$marker = uniqid('', true);
389
-		$this->setAttributeNS(XmlConfigParser::NAMESPACE_AGAVI_ANNOTATIONS_LATEST, 'agavi_annotations_latest:marker', $marker);
387
+        // tag our element, because libxml will mess things up otherwise
388
+        $marker = uniqid('', true);
389
+        $this->setAttributeNS(XmlConfigParser::NAMESPACE_AGAVI_ANNOTATIONS_LATEST, 'agavi_annotations_latest:marker', $marker);
390 390
 		
391
-		if($namespaceUri) {
392
-			$query = 'self::node()[count(child::*[local-name() = "%1$s" and namespace-uri() = "%2$s" and ../@agavi_annotations_latest:marker = "%3$s"]) = 1]/*[local-name() = "%1$s" and namespace-uri() = "%2$s" and ../@agavi_annotations_latest:marker = "%3$s"]';
393
-		} else {
394
-			$query = 'self::node()[count(child::%1$s[../@agavi_annotations_latest:marker = "%3$s"]) = 1]/%1$s[../@agavi_annotations_latest:marker = "%3$s"]';
395
-		}
391
+        if($namespaceUri) {
392
+            $query = 'self::node()[count(child::*[local-name() = "%1$s" and namespace-uri() = "%2$s" and ../@agavi_annotations_latest:marker = "%3$s"]) = 1]/*[local-name() = "%1$s" and namespace-uri() = "%2$s" and ../@agavi_annotations_latest:marker = "%3$s"]';
393
+        } else {
394
+            $query = 'self::node()[count(child::%1$s[../@agavi_annotations_latest:marker = "%3$s"]) = 1]/%1$s[../@agavi_annotations_latest:marker = "%3$s"]';
395
+        }
396 396
 		
397
-		$retval = $this->ownerDocument->getXpath()->query(sprintf($query, $name, $namespaceUri, $marker), $this)->item(0);
397
+        $retval = $this->ownerDocument->getXpath()->query(sprintf($query, $name, $namespaceUri, $marker), $this)->item(0);
398 398
 		
399
-		$this->removeAttributeNS(XmlConfigParser::NAMESPACE_AGAVI_ANNOTATIONS_LATEST, 'agavi_annotations_latest:marker');
399
+        $this->removeAttributeNS(XmlConfigParser::NAMESPACE_AGAVI_ANNOTATIONS_LATEST, 'agavi_annotations_latest:marker');
400 400
 		
401
-		return $retval;
402
-	}
401
+        return $retval;
402
+    }
403 403
 	
404
-	/**
405
-	 * Retrieve an attribute value.
406
-	 * Unlike DOMElement::getAttribute(), this method accepts an optional default
407
-	 * return value.
408
-	 *
409
-	 * @param      string $name    An attribute name.
410
-	 * @param      mixed  $default A default attribute value.
411
-	 *
412
-	 * @return     mixed An attribute value, if the attribute exists, otherwise
413
-	 *                   null or the given default.
414
-	 *
415
-	 * @see        DOMElement::getAttribute()
416
-	 *
417
-	 * @author     David Zülke <[email protected]>
418
-	 * @since      1.0.0
419
-	 */
420
-	public function getAttribute($name, $default = null)
421
-	{
422
-		$retval = parent::getAttribute($name);
404
+    /**
405
+     * Retrieve an attribute value.
406
+     * Unlike DOMElement::getAttribute(), this method accepts an optional default
407
+     * return value.
408
+     *
409
+     * @param      string $name    An attribute name.
410
+     * @param      mixed  $default A default attribute value.
411
+     *
412
+     * @return     mixed An attribute value, if the attribute exists, otherwise
413
+     *                   null or the given default.
414
+     *
415
+     * @see        DOMElement::getAttribute()
416
+     *
417
+     * @author     David Zülke <[email protected]>
418
+     * @since      1.0.0
419
+     */
420
+    public function getAttribute($name, $default = null)
421
+    {
422
+        $retval = parent::getAttribute($name);
423 423
 		
424
-		// getAttribute returns '' when the attribute doesn't exist, but any
425
-		// null-ish value is probably unacceptable anyway
426
-		if($retval == null) {
427
-			$retval = $default;
428
-		}
424
+        // getAttribute returns '' when the attribute doesn't exist, but any
425
+        // null-ish value is probably unacceptable anyway
426
+        if($retval == null) {
427
+            $retval = $default;
428
+        }
429 429
 		
430
-		return $retval;
431
-	}
430
+        return $retval;
431
+    }
432 432
 	
433
-	/**
434
-	 * Retrieve a namespaced attribute value.
435
-	 * Unlike DOMElement::getAttributeNS(), this method accepts an optional
436
-	 * default return value.
437
-	 *
438
-	 * @param      string $namespaceUri A namespace URI.
439
-	 * @param      string $localName    An attribute name.
440
-	 * @param      mixed  $default      A default attribute value.
441
-	 *
442
-	 * @return     mixed An attribute value, if the attribute exists, otherwise
443
-	 *                   null or the given default.
444
-	 *
445
-	 * @see        DOMElement::getAttributeNS()
446
-	 *
447
-	 * @author     David Zülke <[email protected]>
448
-	 * @since      1.0.0
449
-	 */
450
-	public function getAttributeNS($namespaceUri, $localName, $default = null)
451
-	{
452
-		$retval = parent::getAttributeNS($namespaceUri, $localName);
433
+    /**
434
+     * Retrieve a namespaced attribute value.
435
+     * Unlike DOMElement::getAttributeNS(), this method accepts an optional
436
+     * default return value.
437
+     *
438
+     * @param      string $namespaceUri A namespace URI.
439
+     * @param      string $localName    An attribute name.
440
+     * @param      mixed  $default      A default attribute value.
441
+     *
442
+     * @return     mixed An attribute value, if the attribute exists, otherwise
443
+     *                   null or the given default.
444
+     *
445
+     * @see        DOMElement::getAttributeNS()
446
+     *
447
+     * @author     David Zülke <[email protected]>
448
+     * @since      1.0.0
449
+     */
450
+    public function getAttributeNS($namespaceUri, $localName, $default = null)
451
+    {
452
+        $retval = parent::getAttributeNS($namespaceUri, $localName);
453 453
 		
454
-		if($retval === null) {
455
-			$retval = $default;
456
-		}
454
+        if($retval === null) {
455
+            $retval = $default;
456
+        }
457 457
 		
458
-		return $retval;
459
-	}
458
+        return $retval;
459
+    }
460 460
 	
461
-	/**
462
-	 * Retrieve all attributes of the element that are in no namespace.
463
-	 *
464
-	 * @return     array An associative array of attribute names and values.
465
-	 *
466
-	 * @author     David Zülke <[email protected]>
467
-	 * @since      1.0.0
468
-	 */
469
-	public function getAttributes()
470
-	{
471
-		return $this->getAttributesNS('');
472
-	}
461
+    /**
462
+     * Retrieve all attributes of the element that are in no namespace.
463
+     *
464
+     * @return     array An associative array of attribute names and values.
465
+     *
466
+     * @author     David Zülke <[email protected]>
467
+     * @since      1.0.0
468
+     */
469
+    public function getAttributes()
470
+    {
471
+        return $this->getAttributesNS('');
472
+    }
473 473
 	
474
-	/**
475
-	 * Retrieve all attributes of the element that are in the given namespace.
476
-	 *
477
-	 * @return     array An associative array of attribute names and values.
478
-	 *
479
-	 * @author     David Zülke <[email protected]>
480
-	 * @since      1.0.0
481
-	 */
482
-	public function getAttributesNS($namespaceUri)
483
-	{
484
-		$retval = array();
474
+    /**
475
+     * Retrieve all attributes of the element that are in the given namespace.
476
+     *
477
+     * @return     array An associative array of attribute names and values.
478
+     *
479
+     * @author     David Zülke <[email protected]>
480
+     * @since      1.0.0
481
+     */
482
+    public function getAttributesNS($namespaceUri)
483
+    {
484
+        $retval = array();
485 485
 		
486
-		foreach($this->ownerDocument->getXpath()->query(sprintf('@*[namespace-uri() = "%s"]', $namespaceUri), $this) as $attribute) {
487
-			$retval[$attribute->localName] = $attribute->nodeValue;
488
-		}
486
+        foreach($this->ownerDocument->getXpath()->query(sprintf('@*[namespace-uri() = "%s"]', $namespaceUri), $this) as $attribute) {
487
+            $retval[$attribute->localName] = $attribute->nodeValue;
488
+        }
489 489
 		
490
-		return $retval;
491
-	}
490
+        return $retval;
491
+    }
492 492
 	
493
-	/**
494
-	 * Check whether or not the element has Agavi parameters as children.
495
-	 *
496
-	 * @return     bool True, if there are parameters, false otherwise.
497
-	 *
498
-	 * @author     David Zülke <[email protected]>
499
-	 * @since      1.0.0
500
-	 */
501
-	public function hasAgaviParameters()
502
-	{
503
-		if($this->ownerDocument->isAgaviConfiguration()) {
504
-			return $this->has('parameters', XmlConfigParser::NAMESPACE_AGAVI_ENVELOPE_LATEST);
505
-		}
493
+    /**
494
+     * Check whether or not the element has Agavi parameters as children.
495
+     *
496
+     * @return     bool True, if there are parameters, false otherwise.
497
+     *
498
+     * @author     David Zülke <[email protected]>
499
+     * @since      1.0.0
500
+     */
501
+    public function hasAgaviParameters()
502
+    {
503
+        if($this->ownerDocument->isAgaviConfiguration()) {
504
+            return $this->has('parameters', XmlConfigParser::NAMESPACE_AGAVI_ENVELOPE_LATEST);
505
+        }
506 506
 		
507
-		return false;
508
-	}
507
+        return false;
508
+    }
509 509
 	
510
-	/**
511
-	 * Retrieve all of the Agavi parameter elements associated with this
512
-	 * element.
513
-	 *
514
-	 * @param      array An array of existing parameters.
515
-	 *
516
-	 * @return     array The complete array of parameters.
517
-	 *
518
-	 * @author     Noah Fontes <[email protected]>
519
-	 * @author     David Zülke <[email protected]>
520
-	 * @since      1.0.0
521
-	 */
522
-	public function getAgaviParameters(array $existing = array())
523
-	{
524
-		$result = $existing;
525
-		$offset = 0;
510
+    /**
511
+     * Retrieve all of the Agavi parameter elements associated with this
512
+     * element.
513
+     *
514
+     * @param      array An array of existing parameters.
515
+     *
516
+     * @return     array The complete array of parameters.
517
+     *
518
+     * @author     Noah Fontes <[email protected]>
519
+     * @author     David Zülke <[email protected]>
520
+     * @since      1.0.0
521
+     */
522
+    public function getAgaviParameters(array $existing = array())
523
+    {
524
+        $result = $existing;
525
+        $offset = 0;
526 526
 		
527
-		if($this->ownerDocument->isAgaviConfiguration()) {
528
-			$elements = $this->get('parameters', XmlConfigParser::NAMESPACE_AGAVI_ENVELOPE_LATEST);
527
+        if($this->ownerDocument->isAgaviConfiguration()) {
528
+            $elements = $this->get('parameters', XmlConfigParser::NAMESPACE_AGAVI_ENVELOPE_LATEST);
529 529
 
530
-			/** @var XmlConfigDomElement $element */
531
-			foreach($elements as $element) {
532
-				$key = null;
533
-				if(!$element->hasAttribute('name')) {
534
-					$result[$key = $offset++] = null;
535
-				} else {
536
-					$key = $element->getAttribute('name');
537
-				}
530
+            /** @var XmlConfigDomElement $element */
531
+            foreach($elements as $element) {
532
+                $key = null;
533
+                if(!$element->hasAttribute('name')) {
534
+                    $result[$key = $offset++] = null;
535
+                } else {
536
+                    $key = $element->getAttribute('name');
537
+                }
538 538
 				
539
-				if($element->hasAgaviParameters()) {
540
-					$result[$key] = isset($result[$key]) && is_array($result[$key]) ? $result[$key] : array();
541
-					$result[$key] = $element->getAgaviParameters($result[$key]);
542
-				} else {
543
-					$result[$key] = $element->getLiteralValue();
544
-				}
545
-			}
546
-		}
539
+                if($element->hasAgaviParameters()) {
540
+                    $result[$key] = isset($result[$key]) && is_array($result[$key]) ? $result[$key] : array();
541
+                    $result[$key] = $element->getAgaviParameters($result[$key]);
542
+                } else {
543
+                    $result[$key] = $element->getLiteralValue();
544
+                }
545
+            }
546
+        }
547 547
 		
548
-		return $result;
549
-	}
548
+        return $result;
549
+    }
550 550
 }
551 551
 
552 552
 ?>
553 553
\ No newline at end of file
Please login to merge, or discard this patch.
src/config/ValidatorConfigHandler.class.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	/**
50 50
 	 * Execute this configuration handler.
51 51
 	 *
52
-	 * @param      string $document An absolute filesystem path to a configuration file.
52
+	 * @param      XmlConfigDomDocument $document An absolute filesystem path to a configuration file.
53 53
 	 *
54 54
 	 * @return     string Data to be written to a cache file.
55 55
 	 *
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 	 * @param      string               $name The name of the parent container.
233 233
 	 * @param      string               $defaultSeverity The severity of the parent container.
234 234
 	 * @param      string               $defaultMethod The method of the parent container.
235
-	 * @param      bool                 $defaultRequiredWhether parent container is required.
235
+	 * @param      bool                 $defaultRequired parent container is required.
236 236
 	 * @param      string               $defaultTranslationDomain The default translation domain of the parent container.
237 237
 	 *
238 238
 	 * @return     array PHP code blocks that register the validators
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -69,16 +69,16 @@  discard block
 block discarded – undo
69 69
 		
70 70
 		$config = $document->documentURI;
71 71
 		
72
-		$code = array();//array('lines' => array(), 'order' => array());
72
+		$code = array(); //array('lines' => array(), 'order' => array());
73 73
 		
74
-		foreach($document->getConfigurationElements() as $cfg) {
75
-			if($cfg->has('validator_definitions')) {
76
-				foreach($cfg->get('validator_definitions') as $def) {
74
+		foreach ($document->getConfigurationElements() as $cfg) {
75
+			if ($cfg->has('validator_definitions')) {
76
+				foreach ($cfg->get('validator_definitions') as $def) {
77 77
 					$name = $def->getAttribute('name');
78
-					if(!isset($this->classMap[$name])) {
78
+					if (!isset($this->classMap[$name])) {
79 79
 						$this->classMap[$name] = array('class' => $def->getAttribute('class'), 'parameters' => array(), 'errors' => array());
80 80
 					}
81
-					$this->classMap[$name]['class'] = $def->getAttribute('class',$this->classMap[$name]['class']);
81
+					$this->classMap[$name]['class'] = $def->getAttribute('class', $this->classMap[$name]['class']);
82 82
 					$this->classMap[$name]['parameters'] = $def->getAgaviParameters($this->classMap[$name]['parameters']);
83 83
 					$this->classMap[$name]['errors'] = $this->getAgaviErrors($def, $this->classMap[$name]['errors']);
84 84
 				}
@@ -88,14 +88,14 @@  discard block
 block discarded – undo
88 88
 		}
89 89
 
90 90
 		$newCode = array();
91
-		if(isset($code[''])) {
91
+		if (isset($code[''])) {
92 92
 			$newCode = $code[''];
93 93
 			unset($code['']);
94 94
 		}
95 95
 
96
-		foreach($code as $method => $codes) {
96
+		foreach ($code as $method => $codes) {
97 97
 			$newCode[] = 'if($method == ' . var_export($method, true) . ') {';
98
-			foreach($codes as $line) {
98
+			foreach ($codes as $line) {
99 99
 				$newCode[] = $line;
100 100
 			}
101 101
 			$newCode[] = '}';
@@ -126,9 +126,9 @@  discard block
 block discarded – undo
126 126
 	 */
127 127
 	protected function getValidatorArray($validator, $code, $parent, $stdSeverity, $stdMethod, $stdRequired = true, $stdTranslationDomain = null)
128 128
 	{
129
-		if(!isset($this->classMap[$validator->getAttribute('class')])) {
129
+		if (!isset($this->classMap[$validator->getAttribute('class')])) {
130 130
 			$class = $validator->getAttribute('class');
131
-			if(!class_exists($class)) {
131
+			if (!class_exists($class)) {
132 132
 				throw new ValidatorException('unknown validator found: ' . $class);
133 133
 			}
134 134
 			$this->classMap[$class] = array('class' => $class, 'parameters' => array(), 'errors' => array());
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 		
147 147
 		$stdMethod = $validator->getAttribute('method', $stdMethod);
148 148
 		$stdSeverity = $parameters['severity'];
149
-		if($validator->hasAttribute('name')) {
149
+		if ($validator->hasAttribute('name')) {
150 150
 			$name = $validator->getAttribute('name');
151 151
 		} else {
152 152
 			$name = Toolkit::uniqid();
@@ -156,25 +156,25 @@  discard block
 block discarded – undo
156 156
 		$parameters = array_merge($this->classMap[$validator->getAttribute('class')]['parameters'], $parameters);
157 157
 		$parameters = array_merge($parameters, $validator->getAttributes());
158 158
 		$parameters = $validator->getAgaviParameters($parameters);
159
-		if(!array_key_exists('translation_domain', $parameters) && $stdTranslationDomain !== null) {
159
+		if (!array_key_exists('translation_domain', $parameters) && $stdTranslationDomain !== null) {
160 160
 			$parameters['translation_domain'] = $stdTranslationDomain;
161
-		} elseif(isset($parameters['translation_domain']) && $parameters['translation_domain'] === '') {
161
+		} elseif (isset($parameters['translation_domain']) && $parameters['translation_domain'] === '') {
162 162
 			// empty translation domains are forbidden, treat as if translation_domain was not set
163 163
 			unset($parameters['translation_domain']);
164 164
 		}
165 165
 		
166
-		foreach($validator->get('arguments') as $argument) {
167
-			if($argument->hasAttribute('name')) {
166
+		foreach ($validator->get('arguments') as $argument) {
167
+			if ($argument->hasAttribute('name')) {
168 168
 				$arguments[$argument->getAttribute('name')] = $argument->getValue();
169 169
 			} else {
170 170
 				$arguments[] = $argument->getValue();
171 171
 			}
172 172
 		}
173 173
 		
174
-		if($validator->hasChild('arguments')) {
174
+		if ($validator->hasChild('arguments')) {
175 175
 			$parameters['base'] = $validator->getChild('arguments')->getAttribute('base');
176 176
 			
177
-			if(!$arguments) {
177
+			if (!$arguments) {
178 178
 				// no arguments defined, but there is an <arguments /> element, so we're validating an array there
179 179
 				// lets add an empty fake argument for validation to work
180 180
 				// must be an empty string, not null
@@ -184,16 +184,16 @@  discard block
 block discarded – undo
184 184
 		
185 185
 		$errors = $this->getAgaviErrors($validator, $this->classMap[$validator->getAttribute('class')]['errors']);
186 186
 		
187
-		if($validator->hasAttribute('required')) {
187
+		if ($validator->hasAttribute('required')) {
188 188
 			$stdRequired = $parameters['required'] = Toolkit::literalize($validator->getAttribute('required'));
189 189
 		}
190 190
 		
191 191
 		$methods = array('');
192
-		if(trim($stdMethod)) {
192
+		if (trim($stdMethod)) {
193 193
 			$methods = preg_split('/[\s]+/', $stdMethod);
194 194
 		}
195 195
 		
196
-		foreach($methods as $method) {
196
+		foreach ($methods as $method) {
197 197
 			$code[$method][$name] = implode("\n", array(
198 198
 				sprintf(
199 199
 					'${%s} = new %s();',
@@ -247,9 +247,9 @@  discard block
 block discarded – undo
247 247
 	{
248 248
 		// the problem here is that the <validators> parent is not just optional, but can also occur more than once
249 249
 		/** @var XmlConfigDomElement $validator */
250
-		foreach($node->get('validators') as $validator) {
250
+		foreach ($node->get('validators') as $validator) {
251 251
 			// let's see if this buddy has a <validators> parent with valuable information
252
-			if($validator->parentNode->localName == 'validators') {
252
+			if ($validator->parentNode->localName == 'validators') {
253 253
 				$severity = $validator->parentNode->getAttribute('severity', $defaultSeverity);
254 254
 				$method = $validator->parentNode->getAttribute('method', $defaultMethod);
255 255
 				$translationDomain = $validator->parentNode->getAttribute('translation_domain', $defaultTranslationDomain);
@@ -287,9 +287,9 @@  discard block
 block discarded – undo
287 287
 		
288 288
 		$elements = $node->get('errors', self::XML_NAMESPACE);
289 289
 		
290
-		foreach($elements as $element) {
290
+		foreach ($elements as $element) {
291 291
 			$key = '';
292
-			if($element->hasAttribute('for')) {
292
+			if ($element->hasAttribute('for')) {
293 293
 				$key = $element->getAttribute('for');
294 294
 			}
295 295
 			
Please login to merge, or discard this patch.
Indentation   +228 added lines, -228 removed lines patch added patch discarded remove patch
@@ -39,265 +39,265 @@
 block discarded – undo
39 39
  */
40 40
 class ValidatorConfigHandler extends XmlConfigHandler
41 41
 {
42
-	const XML_NAMESPACE = 'http://agavi.org/agavi/config/parts/validators/1.1';
42
+    const XML_NAMESPACE = 'http://agavi.org/agavi/config/parts/validators/1.1';
43 43
 	
44
-	/**
45
-	 * @var        array operator => validator mapping
46
-	 */
47
-	protected $classMap = array();
44
+    /**
45
+     * @var        array operator => validator mapping
46
+     */
47
+    protected $classMap = array();
48 48
 
49
-	/**
50
-	 * Execute this configuration handler.
51
-	 *
52
-	 * @param      string $document An absolute filesystem path to a configuration file.
53
-	 *
54
-	 * @return     string Data to be written to a cache file.
55
-	 *
56
-	 * @throws     <b>UnreadableException</b> If a requested configuration
57
-	 *                                             file does not exist or is not
58
-	 *                                             readable.
59
-	 * @throws     <b>ParseException</b> If a requested configuration file is
60
-	 *                                        improperly formatted.
61
-	 *
62
-	 * @author     Uwe Mesecke <[email protected]>
63
-	 * @author     Dominik del Bondio <[email protected]>
64
-	 * @since      0.11.0
65
-	 */
66
-	public function execute(XmlConfigDomDocument $document)
67
-	{
68
-		$document->setDefaultNamespace(self::XML_NAMESPACE, 'validators');
49
+    /**
50
+     * Execute this configuration handler.
51
+     *
52
+     * @param      string $document An absolute filesystem path to a configuration file.
53
+     *
54
+     * @return     string Data to be written to a cache file.
55
+     *
56
+     * @throws     <b>UnreadableException</b> If a requested configuration
57
+     *                                             file does not exist or is not
58
+     *                                             readable.
59
+     * @throws     <b>ParseException</b> If a requested configuration file is
60
+     *                                        improperly formatted.
61
+     *
62
+     * @author     Uwe Mesecke <[email protected]>
63
+     * @author     Dominik del Bondio <[email protected]>
64
+     * @since      0.11.0
65
+     */
66
+    public function execute(XmlConfigDomDocument $document)
67
+    {
68
+        $document->setDefaultNamespace(self::XML_NAMESPACE, 'validators');
69 69
 		
70
-		$config = $document->documentURI;
70
+        $config = $document->documentURI;
71 71
 		
72
-		$code = array();//array('lines' => array(), 'order' => array());
72
+        $code = array();//array('lines' => array(), 'order' => array());
73 73
 		
74
-		foreach($document->getConfigurationElements() as $cfg) {
75
-			if($cfg->has('validator_definitions')) {
76
-				foreach($cfg->get('validator_definitions') as $def) {
77
-					$name = $def->getAttribute('name');
78
-					if(!isset($this->classMap[$name])) {
79
-						$this->classMap[$name] = array('class' => $def->getAttribute('class'), 'parameters' => array(), 'errors' => array());
80
-					}
81
-					$this->classMap[$name]['class'] = $def->getAttribute('class',$this->classMap[$name]['class']);
82
-					$this->classMap[$name]['parameters'] = $def->getAgaviParameters($this->classMap[$name]['parameters']);
83
-					$this->classMap[$name]['errors'] = $this->getAgaviErrors($def, $this->classMap[$name]['errors']);
84
-				}
85
-			}
74
+        foreach($document->getConfigurationElements() as $cfg) {
75
+            if($cfg->has('validator_definitions')) {
76
+                foreach($cfg->get('validator_definitions') as $def) {
77
+                    $name = $def->getAttribute('name');
78
+                    if(!isset($this->classMap[$name])) {
79
+                        $this->classMap[$name] = array('class' => $def->getAttribute('class'), 'parameters' => array(), 'errors' => array());
80
+                    }
81
+                    $this->classMap[$name]['class'] = $def->getAttribute('class',$this->classMap[$name]['class']);
82
+                    $this->classMap[$name]['parameters'] = $def->getAgaviParameters($this->classMap[$name]['parameters']);
83
+                    $this->classMap[$name]['errors'] = $this->getAgaviErrors($def, $this->classMap[$name]['errors']);
84
+                }
85
+            }
86 86
 			
87
-			$code = $this->processValidatorElements($cfg, $code, 'validationManager');
88
-		}
87
+            $code = $this->processValidatorElements($cfg, $code, 'validationManager');
88
+        }
89 89
 
90
-		$newCode = array();
91
-		if(isset($code[''])) {
92
-			$newCode = $code[''];
93
-			unset($code['']);
94
-		}
90
+        $newCode = array();
91
+        if(isset($code[''])) {
92
+            $newCode = $code[''];
93
+            unset($code['']);
94
+        }
95 95
 
96
-		foreach($code as $method => $codes) {
97
-			$newCode[] = 'if($method == ' . var_export($method, true) . ') {';
98
-			foreach($codes as $line) {
99
-				$newCode[] = $line;
100
-			}
101
-			$newCode[] = '}';
102
-		}
96
+        foreach($code as $method => $codes) {
97
+            $newCode[] = 'if($method == ' . var_export($method, true) . ') {';
98
+            foreach($codes as $line) {
99
+                $newCode[] = $line;
100
+            }
101
+            $newCode[] = '}';
102
+        }
103 103
 
104
-		return $this->generate($newCode, $config);
105
-	}
104
+        return $this->generate($newCode, $config);
105
+    }
106 106
 
107
-	/**
108
-	 * Builds an array of php code strings, each of them creating a validator
109
-	 *
110
-	 * @param      XmlConfigDomElement $validator The value holder of this validator.
111
-	 * @param      array               $code The code of old validators (we simply
112
-	 *                                       overwrite "old" validators here).
113
-	 * @param      string              $parent The name of the parent container.
114
-	 * @param      string              $stdSeverity The severity of the parent container.
115
-	 * @param      string              $stdMethod The method of the parent container.
116
-	 * @param      bool                $stdRequired Whether parent container is required.
117
-	 * @param      string              $stdTranslationDomain The default translation domain of the parent container.
118
-	 *
119
-	 * @return     array PHP code blocks that register the validators
120
-	 *
121
-	 * @author     Uwe Mesecke <[email protected]>
122
-	 * @author     Dominik del Bondio <[email protected]>
123
-	 * @author     David Zülke <[email protected]>
124
-	 * @author     Steffen Gransow <[email protected]>
125
-	 * @since      0.11.0
126
-	 */
127
-	protected function getValidatorArray($validator, $code, $parent, $stdSeverity, $stdMethod, $stdRequired = true, $stdTranslationDomain = null)
128
-	{
129
-		if(!isset($this->classMap[$validator->getAttribute('class')])) {
130
-			$class = $validator->getAttribute('class');
131
-			if(!class_exists($class)) {
132
-				throw new ValidatorException('unknown validator found: ' . $class);
133
-			}
134
-			$this->classMap[$class] = array('class' => $class, 'parameters' => array(), 'errors' => array());
135
-		} else {
136
-			$class = $this->classMap[$validator->getAttribute('class')]['class'];
137
-		}
107
+    /**
108
+     * Builds an array of php code strings, each of them creating a validator
109
+     *
110
+     * @param      XmlConfigDomElement $validator The value holder of this validator.
111
+     * @param      array               $code The code of old validators (we simply
112
+     *                                       overwrite "old" validators here).
113
+     * @param      string              $parent The name of the parent container.
114
+     * @param      string              $stdSeverity The severity of the parent container.
115
+     * @param      string              $stdMethod The method of the parent container.
116
+     * @param      bool                $stdRequired Whether parent container is required.
117
+     * @param      string              $stdTranslationDomain The default translation domain of the parent container.
118
+     *
119
+     * @return     array PHP code blocks that register the validators
120
+     *
121
+     * @author     Uwe Mesecke <[email protected]>
122
+     * @author     Dominik del Bondio <[email protected]>
123
+     * @author     David Zülke <[email protected]>
124
+     * @author     Steffen Gransow <[email protected]>
125
+     * @since      0.11.0
126
+     */
127
+    protected function getValidatorArray($validator, $code, $parent, $stdSeverity, $stdMethod, $stdRequired = true, $stdTranslationDomain = null)
128
+    {
129
+        if(!isset($this->classMap[$validator->getAttribute('class')])) {
130
+            $class = $validator->getAttribute('class');
131
+            if(!class_exists($class)) {
132
+                throw new ValidatorException('unknown validator found: ' . $class);
133
+            }
134
+            $this->classMap[$class] = array('class' => $class, 'parameters' => array(), 'errors' => array());
135
+        } else {
136
+            $class = $this->classMap[$validator->getAttribute('class')]['class'];
137
+        }
138 138
 		
139
-		// setting up parameters
140
-		$parameters = array(
141
-			'severity' => $validator->getAttribute('severity', $stdSeverity),
142
-			'required' => $stdRequired,
143
-		);
139
+        // setting up parameters
140
+        $parameters = array(
141
+            'severity' => $validator->getAttribute('severity', $stdSeverity),
142
+            'required' => $stdRequired,
143
+        );
144 144
 		
145
-		$arguments = array();
145
+        $arguments = array();
146 146
 		
147
-		$stdMethod = $validator->getAttribute('method', $stdMethod);
148
-		$stdSeverity = $parameters['severity'];
149
-		if($validator->hasAttribute('name')) {
150
-			$name = $validator->getAttribute('name');
151
-		} else {
152
-			$name = Toolkit::uniqid();
153
-			$validator->setAttribute('name', $name);
154
-		}
147
+        $stdMethod = $validator->getAttribute('method', $stdMethod);
148
+        $stdSeverity = $parameters['severity'];
149
+        if($validator->hasAttribute('name')) {
150
+            $name = $validator->getAttribute('name');
151
+        } else {
152
+            $name = Toolkit::uniqid();
153
+            $validator->setAttribute('name', $name);
154
+        }
155 155
 		
156
-		$parameters = array_merge($this->classMap[$validator->getAttribute('class')]['parameters'], $parameters);
157
-		$parameters = array_merge($parameters, $validator->getAttributes());
158
-		$parameters = $validator->getAgaviParameters($parameters);
159
-		if(!array_key_exists('translation_domain', $parameters) && $stdTranslationDomain !== null) {
160
-			$parameters['translation_domain'] = $stdTranslationDomain;
161
-		} elseif(isset($parameters['translation_domain']) && $parameters['translation_domain'] === '') {
162
-			// empty translation domains are forbidden, treat as if translation_domain was not set
163
-			unset($parameters['translation_domain']);
164
-		}
156
+        $parameters = array_merge($this->classMap[$validator->getAttribute('class')]['parameters'], $parameters);
157
+        $parameters = array_merge($parameters, $validator->getAttributes());
158
+        $parameters = $validator->getAgaviParameters($parameters);
159
+        if(!array_key_exists('translation_domain', $parameters) && $stdTranslationDomain !== null) {
160
+            $parameters['translation_domain'] = $stdTranslationDomain;
161
+        } elseif(isset($parameters['translation_domain']) && $parameters['translation_domain'] === '') {
162
+            // empty translation domains are forbidden, treat as if translation_domain was not set
163
+            unset($parameters['translation_domain']);
164
+        }
165 165
 		
166
-		foreach($validator->get('arguments') as $argument) {
167
-			if($argument->hasAttribute('name')) {
168
-				$arguments[$argument->getAttribute('name')] = $argument->getValue();
169
-			} else {
170
-				$arguments[] = $argument->getValue();
171
-			}
172
-		}
166
+        foreach($validator->get('arguments') as $argument) {
167
+            if($argument->hasAttribute('name')) {
168
+                $arguments[$argument->getAttribute('name')] = $argument->getValue();
169
+            } else {
170
+                $arguments[] = $argument->getValue();
171
+            }
172
+        }
173 173
 		
174
-		if($validator->hasChild('arguments')) {
175
-			$parameters['base'] = $validator->getChild('arguments')->getAttribute('base');
174
+        if($validator->hasChild('arguments')) {
175
+            $parameters['base'] = $validator->getChild('arguments')->getAttribute('base');
176 176
 			
177
-			if(!$arguments) {
178
-				// no arguments defined, but there is an <arguments /> element, so we're validating an array there
179
-				// lets add an empty fake argument for validation to work
180
-				// must be an empty string, not null
181
-				$arguments[] = '';
182
-			}
183
-		}
177
+            if(!$arguments) {
178
+                // no arguments defined, but there is an <arguments /> element, so we're validating an array there
179
+                // lets add an empty fake argument for validation to work
180
+                // must be an empty string, not null
181
+                $arguments[] = '';
182
+            }
183
+        }
184 184
 		
185
-		$errors = $this->getAgaviErrors($validator, $this->classMap[$validator->getAttribute('class')]['errors']);
185
+        $errors = $this->getAgaviErrors($validator, $this->classMap[$validator->getAttribute('class')]['errors']);
186 186
 		
187
-		if($validator->hasAttribute('required')) {
188
-			$stdRequired = $parameters['required'] = Toolkit::literalize($validator->getAttribute('required'));
189
-		}
187
+        if($validator->hasAttribute('required')) {
188
+            $stdRequired = $parameters['required'] = Toolkit::literalize($validator->getAttribute('required'));
189
+        }
190 190
 		
191
-		$methods = array('');
192
-		if(trim($stdMethod)) {
193
-			$methods = preg_split('/[\s]+/', $stdMethod);
194
-		}
191
+        $methods = array('');
192
+        if(trim($stdMethod)) {
193
+            $methods = preg_split('/[\s]+/', $stdMethod);
194
+        }
195 195
 		
196
-		foreach($methods as $method) {
197
-			$code[$method][$name] = implode("\n", array(
198
-				sprintf(
199
-					'${%s} = new %s();',
200
-					var_export('_validator_' . $name, true),
201
-					$class
202
-				),
203
-				sprintf(
204
-					'${%s}->initialize($this->getContext(), %s, %s, %s);',
205
-					var_export('_validator_' . $name, true),
206
-					var_export($parameters, true),
207
-					var_export($arguments, true),
208
-					var_export($errors, true)
209
-				),
210
-				sprintf(
211
-					'${%s}->addChild(${%s});',
212
-					var_export($parent, true),
213
-					var_export('_validator_' . $name, true)
214
-				),
215
-			));
216
-		}
196
+        foreach($methods as $method) {
197
+            $code[$method][$name] = implode("\n", array(
198
+                sprintf(
199
+                    '${%s} = new %s();',
200
+                    var_export('_validator_' . $name, true),
201
+                    $class
202
+                ),
203
+                sprintf(
204
+                    '${%s}->initialize($this->getContext(), %s, %s, %s);',
205
+                    var_export('_validator_' . $name, true),
206
+                    var_export($parameters, true),
207
+                    var_export($arguments, true),
208
+                    var_export($errors, true)
209
+                ),
210
+                sprintf(
211
+                    '${%s}->addChild(${%s});',
212
+                    var_export($parent, true),
213
+                    var_export('_validator_' . $name, true)
214
+                ),
215
+            ));
216
+        }
217 217
 		
218
-		// more <validator> or <validators> children
219
-		$code = $this->processValidatorElements($validator, $code, '_validator_' . $name, $stdSeverity, $stdMethod, $stdRequired, isset($parameters['translation_domain']) ? $parameters['translation_domain'] : null);
218
+        // more <validator> or <validators> children
219
+        $code = $this->processValidatorElements($validator, $code, '_validator_' . $name, $stdSeverity, $stdMethod, $stdRequired, isset($parameters['translation_domain']) ? $parameters['translation_domain'] : null);
220 220
 		
221
-		return $code;
222
-	}
221
+        return $code;
222
+    }
223 223
 	
224
-	/**
225
-	 * Grabs generated code from the given element.
226
-	 *
227
-	 * @see        ValidatorConfigHandler::getValidatorArray()
228
-	 *
229
-	 * @param      XmlConfigDomElement $node The value holder of this validator.
230
-	 * @param      array                $code The code of old validators (we simply
231
-	 *                                        overwrite "old" validators here).
232
-	 * @param      string               $name The name of the parent container.
233
-	 * @param      string               $defaultSeverity The severity of the parent container.
234
-	 * @param      string               $defaultMethod The method of the parent container.
235
-	 * @param      bool                 $defaultRequiredWhether parent container is required.
236
-	 * @param      string               $defaultTranslationDomain The default translation domain of the parent container.
237
-	 *
238
-	 * @return     array PHP code blocks that register the validators
239
-	 *
240
-	 * @author     Uwe Mesecke <[email protected]>
241
-	 * @author     Dominik del Bondio <[email protected]>
242
-	 * @author     David Zülke <[email protected]>
243
-	 * @author     Steffen Gransow <[email protected]>
244
-	 * @since      0.11.0
245
-	 */
246
-	protected function processValidatorElements(XmlConfigDomElement $node, $code, $name, $defaultSeverity = 'error', $defaultMethod = null, $defaultRequired = true, $defaultTranslationDomain = null)
247
-	{
248
-		// the problem here is that the <validators> parent is not just optional, but can also occur more than once
249
-		/** @var XmlConfigDomElement $validator */
250
-		foreach($node->get('validators') as $validator) {
251
-			// let's see if this buddy has a <validators> parent with valuable information
252
-			if($validator->parentNode->localName == 'validators') {
253
-				$severity = $validator->parentNode->getAttribute('severity', $defaultSeverity);
254
-				$method = $validator->parentNode->getAttribute('method', $defaultMethod);
255
-				$translationDomain = $validator->parentNode->getAttribute('translation_domain', $defaultTranslationDomain);
256
-			} else {
257
-				$severity = $defaultSeverity;
258
-				$method = $defaultMethod;
259
-				$translationDomain = $defaultTranslationDomain;
260
-			}
261
-			$required = $defaultRequired;
224
+    /**
225
+     * Grabs generated code from the given element.
226
+     *
227
+     * @see        ValidatorConfigHandler::getValidatorArray()
228
+     *
229
+     * @param      XmlConfigDomElement $node The value holder of this validator.
230
+     * @param      array                $code The code of old validators (we simply
231
+     *                                        overwrite "old" validators here).
232
+     * @param      string               $name The name of the parent container.
233
+     * @param      string               $defaultSeverity The severity of the parent container.
234
+     * @param      string               $defaultMethod The method of the parent container.
235
+     * @param      bool                 $defaultRequiredWhether parent container is required.
236
+     * @param      string               $defaultTranslationDomain The default translation domain of the parent container.
237
+     *
238
+     * @return     array PHP code blocks that register the validators
239
+     *
240
+     * @author     Uwe Mesecke <[email protected]>
241
+     * @author     Dominik del Bondio <[email protected]>
242
+     * @author     David Zülke <[email protected]>
243
+     * @author     Steffen Gransow <[email protected]>
244
+     * @since      0.11.0
245
+     */
246
+    protected function processValidatorElements(XmlConfigDomElement $node, $code, $name, $defaultSeverity = 'error', $defaultMethod = null, $defaultRequired = true, $defaultTranslationDomain = null)
247
+    {
248
+        // the problem here is that the <validators> parent is not just optional, but can also occur more than once
249
+        /** @var XmlConfigDomElement $validator */
250
+        foreach($node->get('validators') as $validator) {
251
+            // let's see if this buddy has a <validators> parent with valuable information
252
+            if($validator->parentNode->localName == 'validators') {
253
+                $severity = $validator->parentNode->getAttribute('severity', $defaultSeverity);
254
+                $method = $validator->parentNode->getAttribute('method', $defaultMethod);
255
+                $translationDomain = $validator->parentNode->getAttribute('translation_domain', $defaultTranslationDomain);
256
+            } else {
257
+                $severity = $defaultSeverity;
258
+                $method = $defaultMethod;
259
+                $translationDomain = $defaultTranslationDomain;
260
+            }
261
+            $required = $defaultRequired;
262 262
 			
263
-			// append the code to generate
264
-			$code = $this->getValidatorArray($validator, $code, $name, $severity, $method, $required, $translationDomain);
265
-		}
263
+            // append the code to generate
264
+            $code = $this->getValidatorArray($validator, $code, $name, $severity, $method, $required, $translationDomain);
265
+        }
266 266
 		
267
-		return $code;
268
-	}
267
+        return $code;
268
+    }
269 269
 	
270
-	/**
271
-	 * Retrieve all of the Agavi error elements associated with this
272
-	 * element.
273
-	 *
274
-	 * @param      XmlConfigDomElement $node The value holder of this validator.
275
-	 * @param      array               $existing An array of existing errors.
276
-	 *
277
-	 * @return     array The complete array of errors.
278
-	 *
279
-	 * @author     Jan Schütze <[email protected]>
280
-	 * @author     Steffen Gransow <[email protected]>
281
-	 *
282
-	 * @since      1.0.8
283
-	 */
284
-	public function getAgaviErrors(XmlConfigDomElement $node, array $existing = array())
285
-	{
286
-		$result = $existing;
270
+    /**
271
+     * Retrieve all of the Agavi error elements associated with this
272
+     * element.
273
+     *
274
+     * @param      XmlConfigDomElement $node The value holder of this validator.
275
+     * @param      array               $existing An array of existing errors.
276
+     *
277
+     * @return     array The complete array of errors.
278
+     *
279
+     * @author     Jan Schütze <[email protected]>
280
+     * @author     Steffen Gransow <[email protected]>
281
+     *
282
+     * @since      1.0.8
283
+     */
284
+    public function getAgaviErrors(XmlConfigDomElement $node, array $existing = array())
285
+    {
286
+        $result = $existing;
287 287
 		
288
-		$elements = $node->get('errors', self::XML_NAMESPACE);
288
+        $elements = $node->get('errors', self::XML_NAMESPACE);
289 289
 		
290
-		foreach($elements as $element) {
291
-			$key = '';
292
-			if($element->hasAttribute('for')) {
293
-				$key = $element->getAttribute('for');
294
-			}
290
+        foreach($elements as $element) {
291
+            $key = '';
292
+            if($element->hasAttribute('for')) {
293
+                $key = $element->getAttribute('for');
294
+            }
295 295
 			
296
-			$result[$key] = $element->getValue();
297
-		}
296
+            $result[$key] = $element->getValue();
297
+        }
298 298
 		
299
-		return $result;
300
-	}
299
+        return $result;
300
+    }
301 301
 }
302 302
 
303 303
 ?>
Please login to merge, or discard this patch.
src/core/Context.class.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -363,7 +363,7 @@
 block discarded – undo
363 363
 	 * Retrieve a Model implementation instance.
364 364
 	 *
365 365
 	 * @param      string $modelName A model name.
366
-	 * @param      string $moduleNameA module name, if the requested model is a module model,
366
+	 * @param      string $moduleName module name, if the requested model is a module model,
367 367
 	 *                    or null for global models.
368 368
 	 * @param      array  $parameters An array of parameters to be passed to initialize() or
369 369
 	 *                    the constructor.
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 	 */
183 183
 	public function getFactoryInfo($for)
184 184
 	{
185
-		if(isset($this->factories[$for])) {
185
+		if (isset($this->factories[$for])) {
186 186
 			return $this->factories[$for];
187 187
 		}
188 188
 	}
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 	public function createInstanceFor($for)
217 217
 	{
218 218
 		$info = $this->getFactoryInfo($for);
219
-		if(null === $info) {
219
+		if (null === $info) {
220 220
 			throw new AgaviException(sprintf('No factory info for "%s"', $for));
221 221
 		}
222 222
 		
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 	 */
259 259
 	public function getDatabaseConnection($name = null)
260 260
 	{
261
-		if($this->databaseManager !== null) {
261
+		if ($this->databaseManager !== null) {
262 262
 			return $this->databaseManager->getDatabase($name)->getConnection();
263 263
 		}
264 264
 	}
@@ -295,20 +295,20 @@  discard block
 block discarded – undo
295 295
 	public static function getInstance($profile = null)
296 296
 	{
297 297
 		try {
298
-			if($profile === null) {
298
+			if ($profile === null) {
299 299
 				$profile = Config::get('core.default_context');
300
-				if($profile === null) {
300
+				if ($profile === null) {
301 301
 					throw new AgaviException('You must supply a context name to Context::getInstance() or set the name of the default context to be used in the configuration directive "core.default_context".');
302 302
 				}
303 303
 			}
304 304
 			$profile = strtolower($profile);
305
-			if(!isset(self::$instances[$profile])) {
305
+			if (!isset(self::$instances[$profile])) {
306 306
 				$class = Config::get('core.context_implementation', get_called_class());
307 307
 				self::$instances[$profile] = new $class($profile);
308 308
 				self::$instances[$profile]->initialize();
309 309
 			}
310 310
 			return self::$instances[$profile];
311
-		} catch(\Exception $e) {
311
+		} catch (\Exception $e) {
312 312
 			AgaviException::render($e);
313 313
 		}
314 314
 	}
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
 	{
340 340
 		try {
341 341
 			include(ConfigCache::checkConfig(Config::get('core.config_dir') . '/factories.xml', $this->name));
342
-		} catch(\Exception $e) {
342
+		} catch (\Exception $e) {
343 343
 			AgaviException::render($e, $this);
344 344
 		}
345 345
 		
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
 	 */
355 355
 	public function shutdown()
356 356
 	{
357
-		foreach($this->shutdownSequence as $object) {
357
+		foreach ($this->shutdownSequence as $object) {
358 358
 			$object->shutdown();
359 359
 		}
360 360
 	}
@@ -384,17 +384,17 @@  discard block
 block discarded – undo
384 384
 		$file = null;
385 385
 		$rc = null;
386 386
 		
387
-		if($moduleName === null) {
387
+		if ($moduleName === null) {
388 388
 			// global model
389 389
 			// let's try to autoload that baby
390
-			if(!class_exists($class)) {
390
+			if (!class_exists($class)) {
391 391
 				// it's not there. the hunt is on
392 392
 				$file = Config::get('core.model_dir') . '/' . $modelName . 'Model.class.php';
393 393
 			}
394 394
 		} else {
395 395
 			try {
396 396
 				$this->controller->initializeModule($moduleName);
397
-			} catch(DisabledModuleException $e) {
397
+			} catch (DisabledModuleException $e) {
398 398
 				// swallow, this will load the modules autoload but throw an exception 
399 399
 				// if the module is disabled.
400 400
 			}
@@ -402,17 +402,17 @@  discard block
 block discarded – undo
402 402
 			// alternative name
403 403
 			$class = $moduleName . '_' . $class;
404 404
 			// let's try to autoload the baby
405
-			if(!class_exists($class)) {
405
+			if (!class_exists($class)) {
406 406
 				// it's not there. the hunt is on
407 407
 				$file = Config::get('core.module_dir') . '/' . $moduleName . '/models/' . $modelName . 'Model.class.php';
408 408
 			}
409 409
 		}
410 410
 
411
-		if(null !== $file && is_readable($file)) {
411
+		if (null !== $file && is_readable($file)) {
412 412
 			require($file);
413 413
 		}
414 414
 
415
-		if(!class_exists($class)) {
415
+		if (!class_exists($class)) {
416 416
 			// it's not there. 
417 417
 			throw new AgaviException(sprintf("Couldn't find class for Model %s", $origModelName));
418 418
 		}
@@ -421,12 +421,12 @@  discard block
 block discarded – undo
421 421
 		
422 422
 		$rc = new \ReflectionClass($class);
423 423
 		
424
-		if($rc->implementsInterface('Agavi\\Model\\SingletonModelInterface')) {
424
+		if ($rc->implementsInterface('Agavi\\Model\\SingletonModelInterface')) {
425 425
 			// it's a singleton
426
-			if(!isset($this->singletonModelInstances[$class])) {
426
+			if (!isset($this->singletonModelInstances[$class])) {
427 427
 				// no instance yet, so we create one
428 428
 				
429
-				if($parameters === null || $rc->getConstructor() === null) {
429
+				if ($parameters === null || $rc->getConstructor() === null) {
430 430
 					// it has an initialize() method, or no parameters were given, so we don't hand arguments to the constructor
431 431
 					$this->singletonModelInstances[$class] = new $class();
432 432
 				} else {
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
 			$model = $this->singletonModelInstances[$class];
438 438
 		} else {
439 439
 			// create an instance
440
-			if($parameters === null || $rc->getConstructor() === null) {
440
+			if ($parameters === null || $rc->getConstructor() === null) {
441 441
 				// it has an initialize() method, or no parameters were given, so we don't hand arguments to the constructor
442 442
 				$model = new $class();
443 443
 			} else {
@@ -446,9 +446,9 @@  discard block
 block discarded – undo
446 446
 			}
447 447
 		}
448 448
 		
449
-		if(is_callable(array($model, 'initialize'))) {
449
+		if (is_callable(array($model, 'initialize'))) {
450 450
 			// pass the constructor params again. dual use for the win
451
-			$model->initialize($this, (array) $parameters);
451
+			$model->initialize($this, (array)$parameters);
452 452
 		}
453 453
 		
454 454
 		return $model;
Please login to merge, or discard this patch.
Indentation   +433 added lines, -433 removed lines patch added patch discarded remove patch
@@ -56,482 +56,482 @@
 block discarded – undo
56 56
 
57 57
 class Context
58 58
 {
59
-	/**
60
-	 * @var        string The name of the Context.
61
-	 */
62
-	protected $name = '';
59
+    /**
60
+     * @var        string The name of the Context.
61
+     */
62
+    protected $name = '';
63 63
 	
64
-	/**
65
-	 * @var        Dispatcher A Dispatcher instance.
66
-	 */
67
-	protected $dispatcher = null;
64
+    /**
65
+     * @var        Dispatcher A Dispatcher instance.
66
+     */
67
+    protected $dispatcher = null;
68 68
 	
69
-	/**
70
-	 * @var        array An array of class names for frequently used factories.
71
-	 */
72
-	protected $factories = array(
73
-		'dispatch_filter' => null,
74
-		'execution_container' => null,
75
-		'execution_filter' => null,
76
-		'filter_chain' => null,
77
-		'response' => null,
78
-		'security_filter' => null,
79
-		'validation_manager' => null,
80
-	);
69
+    /**
70
+     * @var        array An array of class names for frequently used factories.
71
+     */
72
+    protected $factories = array(
73
+        'dispatch_filter' => null,
74
+        'execution_container' => null,
75
+        'execution_filter' => null,
76
+        'filter_chain' => null,
77
+        'response' => null,
78
+        'security_filter' => null,
79
+        'validation_manager' => null,
80
+    );
81 81
 	
82
-	/**
83
-	 * @var        DatabaseManager A DatabaseManager instance.
84
-	 */
85
-	protected $databaseManager = null;
82
+    /**
83
+     * @var        DatabaseManager A DatabaseManager instance.
84
+     */
85
+    protected $databaseManager = null;
86 86
 	
87
-	/**
88
-	 * @var        LoggerManager A LoggerManager instance.
89
-	 */
90
-	protected $loggerManager = null;
87
+    /**
88
+     * @var        LoggerManager A LoggerManager instance.
89
+     */
90
+    protected $loggerManager = null;
91 91
 	
92
-	/**
93
-	 * @var        Request A Request instance.
94
-	 */
95
-	protected $request = null;
92
+    /**
93
+     * @var        Request A Request instance.
94
+     */
95
+    protected $request = null;
96 96
 	
97
-	/**
98
-	 * @var        Routing A Routing instance.
99
-	 */
100
-	protected $routing = null;
97
+    /**
98
+     * @var        Routing A Routing instance.
99
+     */
100
+    protected $routing = null;
101 101
 	
102
-	/**
103
-	 * @var        Storage A Storage instance.
104
-	 */
105
-	protected $storage = null;
102
+    /**
103
+     * @var        Storage A Storage instance.
104
+     */
105
+    protected $storage = null;
106 106
 	
107
-	/**
108
-	 * @var        TranslationManager A TranslationManager instance.
109
-	 */
110
-	protected $translationManager = null;
107
+    /**
108
+     * @var        TranslationManager A TranslationManager instance.
109
+     */
110
+    protected $translationManager = null;
111 111
 	
112
-	/**
113
-	 * @var        User A User instance.
114
-	 */
115
-	protected $user = null;
112
+    /**
113
+     * @var        User A User instance.
114
+     */
115
+    protected $user = null;
116 116
 	
117
-	/**
118
-	 * @var        array The array used for the shutdown sequence.
119
-	 */
120
-	protected $shutdownSequence = array();
117
+    /**
118
+     * @var        array The array used for the shutdown sequence.
119
+     */
120
+    protected $shutdownSequence = array();
121 121
 	
122
-	/**
123
-	 * @var        array An array of Context instances.
124
-	 */
125
-	protected static $instances = array();
122
+    /**
123
+     * @var        array An array of Context instances.
124
+     */
125
+    protected static $instances = array();
126 126
 	
127
-	/**
128
-	 * @var        array An array of SingletonModel instances.
129
-	 */
130
-	protected $singletonModelInstances = array();
127
+    /**
128
+     * @var        array An array of SingletonModel instances.
129
+     */
130
+    protected $singletonModelInstances = array();
131 131
 
132
-	/**
133
-	 * Clone method, overridden to prevent cloning, there can be only one.
134
-	 *
135
-	 * @author     Mike Vincent <[email protected]>
136
-	 * @since      0.9.0
137
-	 */
138
-	public function __clone()
139
-	{
140
-		trigger_error('Cloning a Context instance is not allowed.', E_USER_ERROR);
141
-	}
132
+    /**
133
+     * Clone method, overridden to prevent cloning, there can be only one.
134
+     *
135
+     * @author     Mike Vincent <[email protected]>
136
+     * @since      0.9.0
137
+     */
138
+    public function __clone()
139
+    {
140
+        trigger_error('Cloning a Context instance is not allowed.', E_USER_ERROR);
141
+    }
142 142
 
143
-	/**
144
-	 * Constructor method, intentionally made protected so the context cannot be
145
-	 * created directly.
146
-	 *
147
-	 * @param      string $name The name of this context.
148
-	 *
149
-	 * @author     David Zülke <[email protected]>
150
-	 * @author     Mike Vincent <[email protected]>
151
-	 * @since      0.9.0
152
-	 */
153
-	protected function __construct($name)
154
-	{
155
-		$this->name = $name;
156
-	}
143
+    /**
144
+     * Constructor method, intentionally made protected so the context cannot be
145
+     * created directly.
146
+     *
147
+     * @param      string $name The name of this context.
148
+     *
149
+     * @author     David Zülke <[email protected]>
150
+     * @author     Mike Vincent <[email protected]>
151
+     * @since      0.9.0
152
+     */
153
+    protected function __construct($name)
154
+    {
155
+        $this->name = $name;
156
+    }
157 157
 
158
-	/**
159
-	 * __toString overload, returns the name of the Context.
160
-	 *
161
-	 * @return     string The context name.
162
-	 *
163
-	 * @see        Context::getName()
164
-	 *
165
-	 * @author     David Zülke <[email protected]>
166
-	 * @since      0.11.0
167
-	 */
168
-	public function __toString()
169
-	{
170
-		return $this->getName();
171
-	}
158
+    /**
159
+     * __toString overload, returns the name of the Context.
160
+     *
161
+     * @return     string The context name.
162
+     *
163
+     * @see        Context::getName()
164
+     *
165
+     * @author     David Zülke <[email protected]>
166
+     * @since      0.11.0
167
+     */
168
+    public function __toString()
169
+    {
170
+        return $this->getName();
171
+    }
172 172
 	
173
-	/**
174
-	 * Get information on a frequently used class.
175
-	 *
176
-	 * @param      string $for The factory identifier.
177
-	 *
178
-	 * @return     array An associative array (keys 'class' and 'parameters').
179
-	 *
180
-	 * @author     David Zülke <[email protected]>
181
-	 * @since      0.11.0
182
-	 */
183
-	public function getFactoryInfo($for)
184
-	{
185
-		if(isset($this->factories[$for])) {
186
-			return $this->factories[$for];
187
-		}
188
-	}
173
+    /**
174
+     * Get information on a frequently used class.
175
+     *
176
+     * @param      string $for The factory identifier.
177
+     *
178
+     * @return     array An associative array (keys 'class' and 'parameters').
179
+     *
180
+     * @author     David Zülke <[email protected]>
181
+     * @since      0.11.0
182
+     */
183
+    public function getFactoryInfo($for)
184
+    {
185
+        if(isset($this->factories[$for])) {
186
+            return $this->factories[$for];
187
+        }
188
+    }
189 189
 	
190
-	/**
191
-	 * Set information on a frequently used class.
192
-	 *
193
-	 * @param      string $for The factory identifier.
194
-	 * @param      array $info An associative array (keys 'class' and 'parameters').
195
-	 *
196
-	 * @author     Felix Gilcher <[email protected]>
197
-	 * @since      1.0.1
198
-	 */
199
-	public function setFactoryInfo($for, array $info)
200
-	{
201
-		$this->factories[$for] = $info;
202
-	}
190
+    /**
191
+     * Set information on a frequently used class.
192
+     *
193
+     * @param      string $for The factory identifier.
194
+     * @param      array $info An associative array (keys 'class' and 'parameters').
195
+     *
196
+     * @author     Felix Gilcher <[email protected]>
197
+     * @since      1.0.1
198
+     */
199
+    public function setFactoryInfo($for, array $info)
200
+    {
201
+        $this->factories[$for] = $info;
202
+    }
203 203
 
204
-	/**
205
-	 * Factory for frequently used classes from factories.xml
206
-	 *
207
-	 * @param      string $for The factory identifier.
208
-	 *
209
-	 * @return     mixed An instance, already initialized with parameters.
210
-	 *
211
-	 * @throws     AgaviException If no such identifier exists.
212
-	 *
213
-	 * @author     David Zülke <[email protected]>
214
-	 * @since      1.0.0
215
-	 */
216
-	public function createInstanceFor($for)
217
-	{
218
-		$info = $this->getFactoryInfo($for);
219
-		if(null === $info) {
220
-			throw new AgaviException(sprintf('No factory info for "%s"', $for));
221
-		}
204
+    /**
205
+     * Factory for frequently used classes from factories.xml
206
+     *
207
+     * @param      string $for The factory identifier.
208
+     *
209
+     * @return     mixed An instance, already initialized with parameters.
210
+     *
211
+     * @throws     AgaviException If no such identifier exists.
212
+     *
213
+     * @author     David Zülke <[email protected]>
214
+     * @since      1.0.0
215
+     */
216
+    public function createInstanceFor($for)
217
+    {
218
+        $info = $this->getFactoryInfo($for);
219
+        if(null === $info) {
220
+            throw new AgaviException(sprintf('No factory info for "%s"', $for));
221
+        }
222 222
 		
223
-		$class = new $info['class']();
224
-		$class->initialize($this, $info['parameters']);
225
-		return $class;
226
-	}
223
+        $class = new $info['class']();
224
+        $class->initialize($this, $info['parameters']);
225
+        return $class;
226
+    }
227 227
 
228
-	/**
229
-	 * Retrieve the Dispatcher.
230
-	 *
231
-	 * @return     Dispatcher The current Dispatcher implementation instance.
232
-	 *
233
-	 * @author     Sean Kerr <[email protected]>
234
-	 * @since      0.9.0
235
-	 */
236
-	public function getDispatcher()
237
-	{
238
-		return $this->dispatcher;
239
-	}
228
+    /**
229
+     * Retrieve the Dispatcher.
230
+     *
231
+     * @return     Dispatcher The current Dispatcher implementation instance.
232
+     *
233
+     * @author     Sean Kerr <[email protected]>
234
+     * @since      0.9.0
235
+     */
236
+    public function getDispatcher()
237
+    {
238
+        return $this->dispatcher;
239
+    }
240 240
 
241
-	/**
242
-	 * Retrieve a database connection from the database manager.
243
-	 *
244
-	 * This is a shortcut to manually getting a connection from an existing
245
-	 * database implementation instance.
246
-	 *
247
-	 * If the core.use_database setting is off, this will return null.
248
-	 *
249
-	 * @param      string $name A database name.
250
-	 *
251
-	 * @return     mixed A database connection.
252
-	 *
253
-	 * @throws     DatabaseException If the requested database name
254
-	 *                                           does not exist.
255
-	 *
256
-	 * @author     Sean Kerr <[email protected]>
257
-	 * @since      0.9.0
258
-	 */
259
-	public function getDatabaseConnection($name = null)
260
-	{
261
-		if($this->databaseManager !== null) {
262
-			return $this->databaseManager->getDatabase($name)->getConnection();
263
-		}
264
-	}
241
+    /**
242
+     * Retrieve a database connection from the database manager.
243
+     *
244
+     * This is a shortcut to manually getting a connection from an existing
245
+     * database implementation instance.
246
+     *
247
+     * If the core.use_database setting is off, this will return null.
248
+     *
249
+     * @param      string $name A database name.
250
+     *
251
+     * @return     mixed A database connection.
252
+     *
253
+     * @throws     DatabaseException If the requested database name
254
+     *                                           does not exist.
255
+     *
256
+     * @author     Sean Kerr <[email protected]>
257
+     * @since      0.9.0
258
+     */
259
+    public function getDatabaseConnection($name = null)
260
+    {
261
+        if($this->databaseManager !== null) {
262
+            return $this->databaseManager->getDatabase($name)->getConnection();
263
+        }
264
+    }
265 265
 
266
-	/**
267
-	 * Retrieve the database manager.
268
-	 *
269
-	 * @return     DatabaseManager The current DatabaseManager instance.
270
-	 *
271
-	 * @author     Sean Kerr <[email protected]>
272
-	 * @since      0.9.0
273
-	 */
274
-	public function getDatabaseManager()
275
-	{
276
-		return $this->databaseManager;
277
-	}
266
+    /**
267
+     * Retrieve the database manager.
268
+     *
269
+     * @return     DatabaseManager The current DatabaseManager instance.
270
+     *
271
+     * @author     Sean Kerr <[email protected]>
272
+     * @since      0.9.0
273
+     */
274
+    public function getDatabaseManager()
275
+    {
276
+        return $this->databaseManager;
277
+    }
278 278
 
279
-	/**
280
-	 * Retrieve the Context instance.
281
-	 *
282
-	 * If you don't supply a profile name this will try to return the context 
283
-	 * specified in the <kbd>core.default_context</kbd> setting.
284
-	 *
285
-	 * @param      string $profile A name corresponding to a section of the config
286
-	 *
287
-	 * @return     Context An context instance initialized with the
288
-	 *                     settings of the requested context name
289
-	 *
290
-	 * @author     Dominik del Bondio <[email protected]>
291
-	 * @author     David Zülke <[email protected]>
292
-	 * @author     Mike Vincent <[email protected]>
293
-	 * @since      0.9.0
294
-	 */
295
-	public static function getInstance($profile = null)
296
-	{
297
-		try {
298
-			if($profile === null) {
299
-				$profile = Config::get('core.default_context');
300
-				if($profile === null) {
301
-					throw new AgaviException('You must supply a context name to Context::getInstance() or set the name of the default context to be used in the configuration directive "core.default_context".');
302
-				}
303
-			}
304
-			$profile = strtolower($profile);
305
-			if(!isset(self::$instances[$profile])) {
306
-				$class = Config::get('core.context_implementation', get_called_class());
307
-				self::$instances[$profile] = new $class($profile);
308
-				self::$instances[$profile]->initialize();
309
-			}
310
-			return self::$instances[$profile];
311
-		} catch(\Exception $e) {
312
-			AgaviException::render($e);
313
-		}
314
-	}
279
+    /**
280
+     * Retrieve the Context instance.
281
+     *
282
+     * If you don't supply a profile name this will try to return the context 
283
+     * specified in the <kbd>core.default_context</kbd> setting.
284
+     *
285
+     * @param      string $profile A name corresponding to a section of the config
286
+     *
287
+     * @return     Context An context instance initialized with the
288
+     *                     settings of the requested context name
289
+     *
290
+     * @author     Dominik del Bondio <[email protected]>
291
+     * @author     David Zülke <[email protected]>
292
+     * @author     Mike Vincent <[email protected]>
293
+     * @since      0.9.0
294
+     */
295
+    public static function getInstance($profile = null)
296
+    {
297
+        try {
298
+            if($profile === null) {
299
+                $profile = Config::get('core.default_context');
300
+                if($profile === null) {
301
+                    throw new AgaviException('You must supply a context name to Context::getInstance() or set the name of the default context to be used in the configuration directive "core.default_context".');
302
+                }
303
+            }
304
+            $profile = strtolower($profile);
305
+            if(!isset(self::$instances[$profile])) {
306
+                $class = Config::get('core.context_implementation', get_called_class());
307
+                self::$instances[$profile] = new $class($profile);
308
+                self::$instances[$profile]->initialize();
309
+            }
310
+            return self::$instances[$profile];
311
+        } catch(\Exception $e) {
312
+            AgaviException::render($e);
313
+        }
314
+    }
315 315
 	
316
-	/**
317
-	 * Retrieve the LoggerManager
318
-	 *
319
-	 * @return     LoggerManager The current LoggerManager implementation
320
-	 *                           instance.
321
-	 *
322
-	 * @author     David Zülke <[email protected]>
323
-	 * @since      0.11.0
324
-	 */
325
-	public function getLoggerManager()
326
-	{
327
-		return $this->loggerManager;
328
-	}
316
+    /**
317
+     * Retrieve the LoggerManager
318
+     *
319
+     * @return     LoggerManager The current LoggerManager implementation
320
+     *                           instance.
321
+     *
322
+     * @author     David Zülke <[email protected]>
323
+     * @since      0.11.0
324
+     */
325
+    public function getLoggerManager()
326
+    {
327
+        return $this->loggerManager;
328
+    }
329 329
 
330
-	/**
331
-	 * (re)Initialize the Context instance.
332
-	 *
333
-	 * @author     Dominik del Bondio <[email protected]>
334
-	 * @author     David Zülke <[email protected]>
335
-	 * @author     Mike Vincent <[email protected]>
336
-	 * @since      0.10.0
337
-	 */
338
-	public function initialize()
339
-	{
340
-		try {
341
-			include(ConfigCache::checkConfig(Config::get('core.config_dir') . '/factories.xml', $this->name));
342
-		} catch(\Exception $e) {
343
-			AgaviException::render($e, $this);
344
-		}
330
+    /**
331
+     * (re)Initialize the Context instance.
332
+     *
333
+     * @author     Dominik del Bondio <[email protected]>
334
+     * @author     David Zülke <[email protected]>
335
+     * @author     Mike Vincent <[email protected]>
336
+     * @since      0.10.0
337
+     */
338
+    public function initialize()
339
+    {
340
+        try {
341
+            include(ConfigCache::checkConfig(Config::get('core.config_dir') . '/factories.xml', $this->name));
342
+        } catch(\Exception $e) {
343
+            AgaviException::render($e, $this);
344
+        }
345 345
 		
346
-		register_shutdown_function(array($this, 'shutdown'));
347
-	}
346
+        register_shutdown_function(array($this, 'shutdown'));
347
+    }
348 348
 	
349
-	/**
350
-	 * Shut down this Context and all related factories.
351
-	 *
352
-	 * @author     David Zülke <[email protected]>
353
-	 * @since      0.11.0
354
-	 */
355
-	public function shutdown()
356
-	{
357
-		foreach($this->shutdownSequence as $object) {
358
-			$object->shutdown();
359
-		}
360
-	}
349
+    /**
350
+     * Shut down this Context and all related factories.
351
+     *
352
+     * @author     David Zülke <[email protected]>
353
+     * @since      0.11.0
354
+     */
355
+    public function shutdown()
356
+    {
357
+        foreach($this->shutdownSequence as $object) {
358
+            $object->shutdown();
359
+        }
360
+    }
361 361
 	
362
-	/**
363
-	 * Retrieve a Model implementation instance.
364
-	 *
365
-	 * @param      string $modelName A model name.
366
-	 * @param      string $moduleNameA module name, if the requested model is a module model,
367
-	 *                    or null for global models.
368
-	 * @param      array  $parameters An array of parameters to be passed to initialize() or
369
-	 *                    the constructor.
370
-	 *
371
-	 * @return     Model A Model implementation instance.
372
-	 *
373
-	 * @throws     AutoloadException if class is ultimately not found.
374
-     *
375
-	 *
376
-	 * @author     David Zülke <[email protected]>
377
-	 * @since      0.11.0
378
-	 */
379
-	public function getModel($modelName, $moduleName = null, array $parameters = null)
380
-	{
381
-		$origModelName = $modelName;
382
-		$modelName = Toolkit::canonicalName($modelName);
383
-		$class = str_replace('/', '_', $modelName) . 'Model';
384
-		$file = null;
385
-		$rc = null;
362
+    /**
363
+     * Retrieve a Model implementation instance.
364
+     *
365
+     * @param      string $modelName A model name.
366
+     * @param      string $moduleNameA module name, if the requested model is a module model,
367
+     *                    or null for global models.
368
+     * @param      array  $parameters An array of parameters to be passed to initialize() or
369
+     *                    the constructor.
370
+     *
371
+     * @return     Model A Model implementation instance.
372
+     *
373
+     * @throws     AutoloadException if class is ultimately not found.
374
+     *
375
+     *
376
+     * @author     David Zülke <[email protected]>
377
+     * @since      0.11.0
378
+     */
379
+    public function getModel($modelName, $moduleName = null, array $parameters = null)
380
+    {
381
+        $origModelName = $modelName;
382
+        $modelName = Toolkit::canonicalName($modelName);
383
+        $class = str_replace('/', '_', $modelName) . 'Model';
384
+        $file = null;
385
+        $rc = null;
386 386
 		
387
-		if($moduleName === null) {
388
-			// global model
389
-			// let's try to autoload that baby
390
-			if(!class_exists($class)) {
391
-				// it's not there. the hunt is on
392
-				$file = Config::get('core.model_dir') . '/' . $modelName . 'Model.class.php';
393
-			}
394
-		} else {
395
-			try {
396
-				$this->dispatcher->initializeModule($moduleName);
397
-			} catch(DisabledModuleException $e) {
398
-				// swallow, this will load the modules autoload but throw an exception 
399
-				// if the module is disabled.
400
-			}
401
-			// module model
402
-			// alternative name
403
-			$class = $moduleName . '_' . $class;
404
-			// let's try to autoload the baby
405
-			if(!class_exists($class)) {
406
-				// it's not there. the hunt is on
407
-				$file = Config::get('core.module_dir') . '/' . $moduleName . '/models/' . $modelName . 'Model.class.php';
408
-			}
409
-		}
387
+        if($moduleName === null) {
388
+            // global model
389
+            // let's try to autoload that baby
390
+            if(!class_exists($class)) {
391
+                // it's not there. the hunt is on
392
+                $file = Config::get('core.model_dir') . '/' . $modelName . 'Model.class.php';
393
+            }
394
+        } else {
395
+            try {
396
+                $this->dispatcher->initializeModule($moduleName);
397
+            } catch(DisabledModuleException $e) {
398
+                // swallow, this will load the modules autoload but throw an exception 
399
+                // if the module is disabled.
400
+            }
401
+            // module model
402
+            // alternative name
403
+            $class = $moduleName . '_' . $class;
404
+            // let's try to autoload the baby
405
+            if(!class_exists($class)) {
406
+                // it's not there. the hunt is on
407
+                $file = Config::get('core.module_dir') . '/' . $moduleName . '/models/' . $modelName . 'Model.class.php';
408
+            }
409
+        }
410 410
 
411
-		if(null !== $file && is_readable($file)) {
412
-			require($file);
413
-		}
411
+        if(null !== $file && is_readable($file)) {
412
+            require($file);
413
+        }
414 414
 
415
-		if(!class_exists($class)) {
416
-			// it's not there. 
417
-			throw new AgaviException(sprintf("Couldn't find class for Model %s", $origModelName));
418
-		}
415
+        if(!class_exists($class)) {
416
+            // it's not there. 
417
+            throw new AgaviException(sprintf("Couldn't find class for Model %s", $origModelName));
418
+        }
419 419
 		
420
-		// so if we're here, we found something, right? good.
420
+        // so if we're here, we found something, right? good.
421 421
 		
422
-		$rc = new \ReflectionClass($class);
422
+        $rc = new \ReflectionClass($class);
423 423
 		
424
-		if($rc->implementsInterface('Agavi\\Model\\SingletonModelInterface')) {
425
-			// it's a singleton
426
-			if(!isset($this->singletonModelInstances[$class])) {
427
-				// no instance yet, so we create one
424
+        if($rc->implementsInterface('Agavi\\Model\\SingletonModelInterface')) {
425
+            // it's a singleton
426
+            if(!isset($this->singletonModelInstances[$class])) {
427
+                // no instance yet, so we create one
428 428
 				
429
-				if($parameters === null || $rc->getConstructor() === null) {
430
-					// it has an initialize() method, or no parameters were given, so we don't hand arguments to the constructor
431
-					$this->singletonModelInstances[$class] = new $class();
432
-				} else {
433
-					// we use this approach so we can pass constructor params or if it doesn't have an initialize() method
434
-					$this->singletonModelInstances[$class] = $rc->newInstanceArgs($parameters);
435
-				}
436
-			}
437
-			$model = $this->singletonModelInstances[$class];
438
-		} else {
439
-			// create an instance
440
-			if($parameters === null || $rc->getConstructor() === null) {
441
-				// it has an initialize() method, or no parameters were given, so we don't hand arguments to the constructor
442
-				$model = new $class();
443
-			} else {
444
-				// we use this approach so we can pass constructor params or if it doesn't have an initialize() method
445
-				$model = $rc->newInstanceArgs($parameters);
446
-			}
447
-		}
429
+                if($parameters === null || $rc->getConstructor() === null) {
430
+                    // it has an initialize() method, or no parameters were given, so we don't hand arguments to the constructor
431
+                    $this->singletonModelInstances[$class] = new $class();
432
+                } else {
433
+                    // we use this approach so we can pass constructor params or if it doesn't have an initialize() method
434
+                    $this->singletonModelInstances[$class] = $rc->newInstanceArgs($parameters);
435
+                }
436
+            }
437
+            $model = $this->singletonModelInstances[$class];
438
+        } else {
439
+            // create an instance
440
+            if($parameters === null || $rc->getConstructor() === null) {
441
+                // it has an initialize() method, or no parameters were given, so we don't hand arguments to the constructor
442
+                $model = new $class();
443
+            } else {
444
+                // we use this approach so we can pass constructor params or if it doesn't have an initialize() method
445
+                $model = $rc->newInstanceArgs($parameters);
446
+            }
447
+        }
448 448
 		
449
-		if(is_callable(array($model, 'initialize'))) {
450
-			// pass the constructor params again. dual use for the win
451
-			$model->initialize($this, (array) $parameters);
452
-		}
449
+        if(is_callable(array($model, 'initialize'))) {
450
+            // pass the constructor params again. dual use for the win
451
+            $model->initialize($this, (array) $parameters);
452
+        }
453 453
 		
454
-		return $model;
455
-	}
454
+        return $model;
455
+    }
456 456
 
457
-	/**
458
-	 * Retrieve the name of this Context.
459
-	 *
460
-	 * @return     string A context name.
461
-	 *
462
-	 * @author     David Zülke <[email protected]>
463
-	 * @since      0.11.0
464
-	 */
465
-	public function getName()
466
-	{
467
-		return $this->name;
468
-	}
457
+    /**
458
+     * Retrieve the name of this Context.
459
+     *
460
+     * @return     string A context name.
461
+     *
462
+     * @author     David Zülke <[email protected]>
463
+     * @since      0.11.0
464
+     */
465
+    public function getName()
466
+    {
467
+        return $this->name;
468
+    }
469 469
 	
470
-	/**
471
-	 * Retrieve the request.
472
-	 *
473
-	 * @return     Request The current Request implementation instance.
474
-	 *
475
-	 * @author     Sean Kerr <[email protected]>
476
-	 * @since      0.9.0
477
-	 */
478
-	public function getRequest()
479
-	{
480
-		return $this->request;
481
-	}
470
+    /**
471
+     * Retrieve the request.
472
+     *
473
+     * @return     Request The current Request implementation instance.
474
+     *
475
+     * @author     Sean Kerr <[email protected]>
476
+     * @since      0.9.0
477
+     */
478
+    public function getRequest()
479
+    {
480
+        return $this->request;
481
+    }
482 482
 
483
-	/**
484
-	 * Retrieve the routing.
485
-	 *
486
-	 * @return     Routing The current Routing implementation instance.
487
-	 *
488
-	 * @author     Dominik del Bondio <[email protected]>
489
-	 * @since      0.11.0
490
-	 */
491
-	public function getRouting()
492
-	{
493
-		return $this->routing;
494
-	}
483
+    /**
484
+     * Retrieve the routing.
485
+     *
486
+     * @return     Routing The current Routing implementation instance.
487
+     *
488
+     * @author     Dominik del Bondio <[email protected]>
489
+     * @since      0.11.0
490
+     */
491
+    public function getRouting()
492
+    {
493
+        return $this->routing;
494
+    }
495 495
 
496
-	/**
497
-	 * Retrieve the storage.
498
-	 *
499
-	 * @return     Storage The current Storage implementation instance.
500
-	 *
501
-	 * @author     Sean Kerr <[email protected]>
502
-	 * @since      0.9.0
503
-	 */
504
-	public function getStorage()
505
-	{
506
-		return $this->storage;
507
-	}
496
+    /**
497
+     * Retrieve the storage.
498
+     *
499
+     * @return     Storage The current Storage implementation instance.
500
+     *
501
+     * @author     Sean Kerr <[email protected]>
502
+     * @since      0.9.0
503
+     */
504
+    public function getStorage()
505
+    {
506
+        return $this->storage;
507
+    }
508 508
 
509
-	/**
510
-	 * Retrieve the translation manager.
511
-	 *
512
-	 * @return     TranslationManager The current TranslationManager
513
-	 *                                     implementation instance.
514
-	 *
515
-	 * @author     Dominik del Bondio <[email protected]>
516
-	 * @since      0.11.0
517
-	 */
518
-	public function getTranslationManager()
519
-	{
520
-		return $this->translationManager;
521
-	}
509
+    /**
510
+     * Retrieve the translation manager.
511
+     *
512
+     * @return     TranslationManager The current TranslationManager
513
+     *                                     implementation instance.
514
+     *
515
+     * @author     Dominik del Bondio <[email protected]>
516
+     * @since      0.11.0
517
+     */
518
+    public function getTranslationManager()
519
+    {
520
+        return $this->translationManager;
521
+    }
522 522
 
523
-	/**
524
-	 * Retrieve the user.
525
-	 *
526
-	 * @return     User The current User implementation instance.
527
-	 *
528
-	 * @author     Sean Kerr <[email protected]>
529
-	 * @since      0.9.0
530
-	 */
531
-	public function getUser()
532
-	{
533
-		return $this->user;
534
-	}
523
+    /**
524
+     * Retrieve the user.
525
+     *
526
+     * @return     User The current User implementation instance.
527
+     *
528
+     * @author     Sean Kerr <[email protected]>
529
+     * @since      0.9.0
530
+     */
531
+    public function getUser()
532
+    {
533
+        return $this->user;
534
+    }
535 535
 }
536 536
 
537 537
 ?>
538 538
\ No newline at end of file
Please login to merge, or discard this patch.
src/database/DatabaseManager.class.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@
 block discarded – undo
71 71
 	 * Retrieve the database connection associated with this Database
72 72
 	 * implementation.
73 73
 	 *
74
-	 * @param      string $nme A database name.
74
+	 * @param      string $name A database name.
75 75
 	 *
76 76
 	 * @return     mixed A Database instance.
77 77
 	 *
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -83,11 +83,11 @@  discard block
 block discarded – undo
83 83
 	 */
84 84
 	public function getDatabase($name = null)
85 85
 	{
86
-		if($name === null) {
86
+		if ($name === null) {
87 87
 			$name = $this->defaultDatabaseName;
88 88
 		}
89 89
 		
90
-		if(isset($this->databases[$name])) {
90
+		if (isset($this->databases[$name])) {
91 91
 			return $this->databases[$name];
92 92
 		}
93 93
 
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 	public function startup()
157 157
 	{
158 158
 		/** @var Database $database */
159
-		foreach($this->databases as $database) {
159
+		foreach ($this->databases as $database) {
160 160
 			$database->startup();
161 161
 		}
162 162
 	}
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 	public function shutdown()
174 174
 	{
175 175
 		// loop through databases and shutdown connections
176
-		foreach($this->databases as $database) {
176
+		foreach ($this->databases as $database) {
177 177
 			$database->shutdown();
178 178
 		}
179 179
 	}
Please login to merge, or discard this patch.
Indentation   +126 added lines, -126 removed lines patch added patch discarded remove patch
@@ -39,144 +39,144 @@
 block discarded – undo
39 39
  */
40 40
 class DatabaseManager
41 41
 {
42
-	/**
43
-	 * @var        string The name of the default database.
44
-	 */
45
-	protected $defaultDatabaseName = null;
42
+    /**
43
+     * @var        string The name of the default database.
44
+     */
45
+    protected $defaultDatabaseName = null;
46 46
 	
47
-	/**
48
-	 * @var        array An array of AgaviDatabases.
49
-	 */
50
-	protected $databases = array();
47
+    /**
48
+     * @var        array An array of AgaviDatabases.
49
+     */
50
+    protected $databases = array();
51 51
 
52
-	/**
53
-	 * @var        Context A Context instance.
54
-	 */
55
-	protected $context = null;
52
+    /**
53
+     * @var        Context A Context instance.
54
+     */
55
+    protected $context = null;
56 56
 
57
-	/**
58
-	 * Retrieve the current application context.
59
-	 *
60
-	 * @return     Context The current Context instance.
61
-	 *
62
-	 * @author     David Zülke <[email protected]>
63
-	 * @since      0.11.0
64
-	 */
65
-	public final function getContext()
66
-	{
67
-		return $this->context;
68
-	}
57
+    /**
58
+     * Retrieve the current application context.
59
+     *
60
+     * @return     Context The current Context instance.
61
+     *
62
+     * @author     David Zülke <[email protected]>
63
+     * @since      0.11.0
64
+     */
65
+    public final function getContext()
66
+    {
67
+        return $this->context;
68
+    }
69 69
 
70
-	/**
71
-	 * Retrieve the database connection associated with this Database
72
-	 * implementation.
73
-	 *
74
-	 * @param      string $nme A database name.
75
-	 *
76
-	 * @return     mixed A Database instance.
77
-	 *
78
-	 * @throws     DatabaseException If the requested database name does not exist.
79
-	 *
80
-	 * @author     David Zülke <[email protected]>
81
-	 * @author     Sean Kerr <[email protected]>
82
-	 * @since      0.9.0
83
-	 */
84
-	public function getDatabase($name = null)
85
-	{
86
-		if($name === null) {
87
-			$name = $this->defaultDatabaseName;
88
-		}
70
+    /**
71
+     * Retrieve the database connection associated with this Database
72
+     * implementation.
73
+     *
74
+     * @param      string $nme A database name.
75
+     *
76
+     * @return     mixed A Database instance.
77
+     *
78
+     * @throws     DatabaseException If the requested database name does not exist.
79
+     *
80
+     * @author     David Zülke <[email protected]>
81
+     * @author     Sean Kerr <[email protected]>
82
+     * @since      0.9.0
83
+     */
84
+    public function getDatabase($name = null)
85
+    {
86
+        if($name === null) {
87
+            $name = $this->defaultDatabaseName;
88
+        }
89 89
 		
90
-		if(isset($this->databases[$name])) {
91
-			return $this->databases[$name];
92
-		}
90
+        if(isset($this->databases[$name])) {
91
+            return $this->databases[$name];
92
+        }
93 93
 
94
-		// nonexistent database name
95
-		$error = 'Database "%s" does not exist';
96
-		$error = sprintf($error, $name);
97
-		throw new DatabaseException($error);
98
-	}
94
+        // nonexistent database name
95
+        $error = 'Database "%s" does not exist';
96
+        $error = sprintf($error, $name);
97
+        throw new DatabaseException($error);
98
+    }
99 99
 	
100
-	/**
101
-	 * Retrieve the name of the given database instance.
102
-	 *
103
-	 * @param      Database $database The database to fetch the name of.
104
-	 *
105
-	 * @return     string The name of the database, or false if it was not found.
106
-	 *
107
-	 * @author     David Zülke <[email protected]>
108
-	 * @since      0.11.0
109
-	 */
110
-	public function getDatabaseName(Database $database)
111
-	{
112
-		return array_search($database, $this->databases, true);
113
-	}
100
+    /**
101
+     * Retrieve the name of the given database instance.
102
+     *
103
+     * @param      Database $database The database to fetch the name of.
104
+     *
105
+     * @return     string The name of the database, or false if it was not found.
106
+     *
107
+     * @author     David Zülke <[email protected]>
108
+     * @since      0.11.0
109
+     */
110
+    public function getDatabaseName(Database $database)
111
+    {
112
+        return array_search($database, $this->databases, true);
113
+    }
114 114
 
115
-	/**
116
-	 * Returns the name of the default database.
117
-	 *
118
-	 * @return     string The name of the default database.
119
-	 *
120
-	 * @author     David Zülke <[email protected]>
121
-	 * @since      0.11.0
122
-	 */
123
-	public function getDefaultDatabaseName()
124
-	{
125
-		return $this->defaultDatabaseName;
126
-	}
115
+    /**
116
+     * Returns the name of the default database.
117
+     *
118
+     * @return     string The name of the default database.
119
+     *
120
+     * @author     David Zülke <[email protected]>
121
+     * @since      0.11.0
122
+     */
123
+    public function getDefaultDatabaseName()
124
+    {
125
+        return $this->defaultDatabaseName;
126
+    }
127 127
 
128
-	/**
129
-	 * Initialize this DatabaseManager.
130
-	 *
131
-	 * @param      Context $context    A Context instance.
132
-	 * @param      array   $parameters An array of initialization parameters.
133
-	 *
134
-	 * @throws     InitializationException If an error occurs while initializing this DatabaseManager.
135
-	 *
136
-	 * @author     David Zülke <[email protected]>
137
-	 * @author     Sean Kerr <[email protected]>
138
-	 * @since      0.9.0
139
-	 */
140
-	public function initialize(Context $context, array $parameters = array())
141
-	{
142
-		$this->context = $context;
128
+    /**
129
+     * Initialize this DatabaseManager.
130
+     *
131
+     * @param      Context $context    A Context instance.
132
+     * @param      array   $parameters An array of initialization parameters.
133
+     *
134
+     * @throws     InitializationException If an error occurs while initializing this DatabaseManager.
135
+     *
136
+     * @author     David Zülke <[email protected]>
137
+     * @author     Sean Kerr <[email protected]>
138
+     * @since      0.9.0
139
+     */
140
+    public function initialize(Context $context, array $parameters = array())
141
+    {
142
+        $this->context = $context;
143 143
 
144
-		// load database configuration
145
-		require(ConfigCache::checkConfig(Config::get('core.config_dir') . '/databases.xml'));
146
-	}
144
+        // load database configuration
145
+        require(ConfigCache::checkConfig(Config::get('core.config_dir') . '/databases.xml'));
146
+    }
147 147
 
148
-	/**
149
-	 * Do any necessary startup work after initialization.
150
-	 *
151
-	 * This method is not called directly after initialize().
152
-	 *
153
-	 * @author     David Zülke <[email protected]>
154
-	 * @since      0.11.0
155
-	 */
156
-	public function startup()
157
-	{
158
-		/** @var Database $database */
159
-		foreach($this->databases as $database) {
160
-			$database->startup();
161
-		}
162
-	}
148
+    /**
149
+     * Do any necessary startup work after initialization.
150
+     *
151
+     * This method is not called directly after initialize().
152
+     *
153
+     * @author     David Zülke <[email protected]>
154
+     * @since      0.11.0
155
+     */
156
+    public function startup()
157
+    {
158
+        /** @var Database $database */
159
+        foreach($this->databases as $database) {
160
+            $database->startup();
161
+        }
162
+    }
163 163
 
164
-	/**
165
-	 * Execute the shutdown procedure.
166
-	 *
167
-	 * @throws     <b>AgaviDatabaseException</b> If an error occurs while shutting
168
-	 *                                           down this DatabaseManager.
169
-	 *
170
-	 * @author     Sean Kerr <[email protected]>
171
-	 * @since      0.9.0
172
-	 */
173
-	public function shutdown()
174
-	{
175
-		// loop through databases and shutdown connections
176
-		foreach($this->databases as $database) {
177
-			$database->shutdown();
178
-		}
179
-	}
164
+    /**
165
+     * Execute the shutdown procedure.
166
+     *
167
+     * @throws     <b>AgaviDatabaseException</b> If an error occurs while shutting
168
+     *                                           down this DatabaseManager.
169
+     *
170
+     * @author     Sean Kerr <[email protected]>
171
+     * @since      0.9.0
172
+     */
173
+    public function shutdown()
174
+    {
175
+        // loop through databases and shutdown connections
176
+        foreach($this->databases as $database) {
177
+            $database->shutdown();
178
+        }
179
+    }
180 180
 }
181 181
 
182 182
 ?>
183 183
\ No newline at end of file
Please login to merge, or discard this patch.