[Beeframework-svn] SF.net SVN: beeframework:[153] trunk/framework/Bee/Context
Brought to you by:
b_hartmann,
m_plomer
|
From: <m_p...@us...> - 2014-06-18 13:09:13
|
Revision: 153
http://sourceforge.net/p/beeframework/code/153
Author: m_plomer
Date: 2014-06-18 13:09:08 +0000 (Wed, 18 Jun 2014)
Log Message:
-----------
- numeric-keys parameter introduced for arrays
Modified Paths:
--------------
trunk/framework/Bee/Context/Config/ArrayValue.php
trunk/framework/Bee/Context/Xml/ParserDelegate.php
Modified: trunk/framework/Bee/Context/Config/ArrayValue.php
===================================================================
--- trunk/framework/Bee/Context/Config/ArrayValue.php 2014-06-18 12:24:38 UTC (rev 152)
+++ trunk/framework/Bee/Context/Config/ArrayValue.php 2014-06-18 13:09:08 UTC (rev 153)
@@ -35,10 +35,13 @@
private $associative = false;
- public function __construct(array &$sourceArray, $mergeEnabled = false, $associative = false) {
+ private $numericKeys = false;
+
+ public function __construct(array &$sourceArray, $mergeEnabled = false, $associative = false, $numericKeys = false) {
$this->sourceArray =& $sourceArray;
$this->mergeEnabled = $mergeEnabled;
$this->associative = $associative;
+ $this->numericKeys = $numericKeys;
}
/**
@@ -83,18 +86,23 @@
function merge(Traversable $parent) {
$tmpArray = array();
$parentAssoc = $parent instanceof Bee_Context_Config_ArrayValue && $parent->associative;
- foreach ($parent as $key => $value) {
- if($parentAssoc) {
- $tmpArray[$key] = $value;
- } else {
- array_push($tmpArray, $value);
+ if($parentAssoc && $this->associative && $parent->numericKeys && $this->numericKeys) {
+ $tmpArray = array_replace($parent->sourceArray, $this->sourceArray);
+ ksort($tmpArray);
+ } else {
+ foreach ($parent as $key => $value) {
+ if($parentAssoc) {
+ $tmpArray[$key] = $value;
+ } else {
+ array_push($tmpArray, $value);
+ }
}
- }
- foreach ($this->sourceArray as $key => $value) {
- if($this->associative) {
- $tmpArray[$key] = $value;
- } else {
- array_push($tmpArray, $value);
+ foreach ($this->sourceArray as $key => $value) {
+ if($this->associative) {
+ $tmpArray[$key] = $value;
+ } else {
+ array_push($tmpArray, $value);
+ }
}
}
$this->sourceArray =& $tmpArray;
Modified: trunk/framework/Bee/Context/Xml/ParserDelegate.php
===================================================================
--- trunk/framework/Bee/Context/Xml/ParserDelegate.php 2014-06-18 12:24:38 UTC (rev 152)
+++ trunk/framework/Bee/Context/Xml/ParserDelegate.php 2014-06-18 13:09:08 UTC (rev 153)
@@ -647,7 +647,7 @@
$this->readerContext->error('Must not combine \'assoc-item\' elements and other elements in the same \'array\' element!', $collectionEle);
}
}
- return new Bee_Context_Config_ArrayValue($list, $this->parseMergeAttribute($collectionEle), $assoc);
+ return new Bee_Context_Config_ArrayValue($list, $this->parseMergeAttribute($collectionEle), $assoc, $numericKeys);
}
public function parseMergeAttribute(DOMElement $collectionElement) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|