mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
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:
parent
fcded47353
commit
742984cb49
@ -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])) {
|
||||
|
@ -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');
|
||||
?>
|
||||
?>
|
||||
|
Loading…
Reference in New Issue
Block a user