mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
ArrayData should only change the type of included objects if they're not ViewableData.
Included regression test git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@60473 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
130ecfe5aa
commit
a99accbea4
@ -35,7 +35,7 @@ class ArrayData extends ViewableData {
|
||||
}
|
||||
|
||||
public function getField($f) {
|
||||
if((is_object($this->array[$f]) && !$this->array[$f] instanceof ArrayData) || (is_array($this->array[$f]) && ArrayLib::is_associative($this->array[$f]))) {
|
||||
if((is_object($this->array[$f]) && !$this->array[$f] instanceof ViewableData) || (is_array($this->array[$f]) && ArrayLib::is_associative($this->array[$f]))) {
|
||||
return new ArrayData($this->array[$f]);
|
||||
} else {
|
||||
return $this->array[$f];
|
||||
@ -66,6 +66,7 @@ class ArrayData extends ViewableData {
|
||||
* This is pretty crude, but it helps diagnose error situations
|
||||
*/
|
||||
function forTemplate() {
|
||||
return "(ArrayData)";
|
||||
return var_export($this->array, true);
|
||||
}
|
||||
|
||||
|
14
tests/ArrayDataTest.php
Normal file
14
tests/ArrayDataTest.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
class ArrayDataTest extends SapphireTest {
|
||||
|
||||
function testViewabledataItemsInsideArraydataArePreserved() {
|
||||
/* ViewableData objects will be preserved, but other objects will be converted */
|
||||
$arrayData = new ArrayData(array(
|
||||
"A" => new Varchar("A"),
|
||||
"B" => new Object(),
|
||||
));
|
||||
$this->assertEquals("Varchar", get_class($arrayData->A));
|
||||
$this->assertEquals("ArrayData", get_class($arrayData->B));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user