BUGFIX: Fixed bugs in ViewableData casting system.

From: Sam Minnee <sam@silverstripe.com>

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@88664 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2009-10-12 06:58:40 +00:00
parent 1bcb5a6fc7
commit 24435fbbf7
3 changed files with 1 additions and 31 deletions

View File

@ -307,11 +307,7 @@ class ViewableData extends Object implements IteratorAggregate {
foreach($ancestry as $class) {
if(!isset(self::$casting_cache[$class]) && $merge) {
if($class instanceof DataObject) {
$mergeFields = array('db', 'casting');
} else {
$mergeFields = array('casting');
}
$mergeFields = is_subclass_of($class, 'DataObject') ? array('db', 'casting') : array('casting');
if($mergeFields) foreach($mergeFields as $field) {
$casting = Object::uninherited_static($class, $field);

View File

@ -90,11 +90,6 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
$cache_has_own_table = array(),
$cache_has_own_table_field = array();
public static $casting_properties = array (
'db',
'casting'
);
/**
* True if this DataObject has been destroyed.
* @var boolean

View File

@ -15,15 +15,6 @@ class ViewableDataTest extends SapphireTest {
$this->assertFalse($caster->obj('noCastingInformation', null, false) instanceof ViewableData_Caster);
}
public function testCastingProperties() {
$caster = new ViewableData_CastingProperties();
$caster->buildCastingCache($cache);
$this->assertTrue(isset($cache['Foo']));
$this->assertEquals('Bar', $cache['Foo']['className']);
$this->assertEquals('Bar', $caster->castingClass('Foo'));
}
public function testCastingXMLVal() {
$caster = new ViewableDataTest_Castable();
@ -94,18 +85,6 @@ class ViewableDataTest_Castable extends ViewableData {
}
class ViewableData_CastingProperties extends ViewableData {
public static $casting_properties = array (
'test'
);
public static $test = array (
'Foo' => 'Bar'
);
}
class ViewableDataTest_RequiresCasting extends ViewableData {
public $test = 'overwritten';