BUGFIX: Allow extraDBFields() on decorators for compatibility, throw a deprecated notice

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@79599 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Andrew O'Neil 2009-06-19 00:58:02 +00:00
parent fcded47353
commit 742984cb49
2 changed files with 11 additions and 4 deletions

View File

@ -47,12 +47,19 @@ abstract class DataObjectDecorator extends Extension {
if(!empty(self::$extra_statics_loaded[$class][$extension])) return;
self::$extra_statics_loaded[$class][$extension] = true;
if(!method_exists($extension, 'extraStatics')) return;
// @deprecated 2.4 - use extraStatics() now, not extraDBFields()
if(method_exists($extension, 'extraDBFields')) {
user_error('DataObjectDecorator::extraDBFields() is deprecated. Please use extraStatics() instead.', E_USER_NOTICE);
$extraStaticsMethod = 'extraDBFields';
} else {
$extraStaticsMethod = 'extraStatics';
}
// If the extension has been manually applied to a subclass, we should ignore that.
if(Object::has_extension(get_parent_class($class), $extension)) return;
$statics = call_user_func(array($extension, 'extraStatics'));
$statics = call_user_func(array($extension, $extraStaticsMethod));
if($statics) {
foreach($statics as $name => $newVal) {
if(isset(self::$decoratable_statics[$name])) {

View File

@ -260,7 +260,7 @@ class DataObjectDecoratorTest_Ext2 extends DataObjectDecorator implements TestOn
}
class DataObjectDecoratorTest_Faves extends DataObjectDecorator implements TestOnly {
public function extraDBFields() {
public function extraStatics() {
return array(
'many_many' => array(
'Faves' => 'Page'
@ -272,4 +272,4 @@ class DataObjectDecoratorTest_Faves extends DataObjectDecorator implements TestO
DataObject::add_extension('DataObjectDecoratorTest_MyObject', 'DataObjectDecoratorTest_Ext1');
DataObject::add_extension('DataObjectDecoratorTest_MyObject', 'DataObjectDecoratorTest_Ext2');
DataObject::add_extension('DataObjectDecoratorTest_MyObject', 'DataObjectDecoratorTest_Faves');
?>
?>