mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
API CHANGE: Pass the full extension string as the 2nd argument to DataObjectDecorator::extraStatics()
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@101043 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
d084a7053f
commit
2a22e73615
@ -439,7 +439,7 @@ abstract class Object {
|
|||||||
|
|
||||||
// load statics now for DataObject classes
|
// load statics now for DataObject classes
|
||||||
if(ClassInfo::is_subclass_of($class, 'DataObject')) {
|
if(ClassInfo::is_subclass_of($class, 'DataObject')) {
|
||||||
DataObjectDecorator::load_extra_statics($class, $extensionClass);
|
DataObjectDecorator::load_extra_statics($class, $extension);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -456,10 +456,7 @@ abstract class Object {
|
|||||||
if(is_subclass_of($class, 'DataObject')) {
|
if(is_subclass_of($class, 'DataObject')) {
|
||||||
$extensions = Object::uninherited_static($class, 'extensions');
|
$extensions = Object::uninherited_static($class, 'extensions');
|
||||||
if($extensions) foreach($extensions as $extension) {
|
if($extensions) foreach($extensions as $extension) {
|
||||||
if(preg_match('/^([^(]*)/', $extension, $matches)) {
|
DataObjectDecorator::load_extra_statics($class, $extension);
|
||||||
$extensionClass = $matches[1];
|
|
||||||
DataObjectDecorator::load_extra_statics($class, $extensionClass);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -462,7 +462,6 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
$class = get_class($instance);
|
$class = get_class($instance);
|
||||||
user_error("DataObject::defineMethods(): Please ensure {$class}::__construct() calls parent::__construct()", E_USER_ERROR);
|
user_error("DataObject::defineMethods(): Please ensure {$class}::__construct() calls parent::__construct()", E_USER_ERROR);
|
||||||
}
|
}
|
||||||
DataObjectDecorator::load_extra_statics($this->class, $instance->class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up accessors for joined items
|
// Set up accessors for joined items
|
||||||
|
@ -48,8 +48,15 @@ abstract class DataObjectDecorator extends Extension {
|
|||||||
if(!empty(self::$extra_statics_loaded[$class][$extension])) return;
|
if(!empty(self::$extra_statics_loaded[$class][$extension])) return;
|
||||||
self::$extra_statics_loaded[$class][$extension] = true;
|
self::$extra_statics_loaded[$class][$extension] = true;
|
||||||
|
|
||||||
|
if(preg_match('/^([^(]*)/', $extension, $matches)) {
|
||||||
|
$extensionClass = $matches[1];
|
||||||
|
} else {
|
||||||
|
user_error("Bad extenion '$extension' - can't find classname", E_USER_WARNING);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// @deprecated 2.4 - use extraStatics() now, not extraDBFields()
|
// @deprecated 2.4 - use extraStatics() now, not extraDBFields()
|
||||||
if(method_exists($extension, 'extraDBFields')) {
|
if(method_exists($extensionClass, 'extraDBFields')) {
|
||||||
user_error('DataObjectDecorator::extraDBFields() is deprecated. Please use extraStatics() instead.', E_USER_NOTICE);
|
user_error('DataObjectDecorator::extraDBFields() is deprecated. Please use extraStatics() instead.', E_USER_NOTICE);
|
||||||
$extraStaticsMethod = 'extraDBFields';
|
$extraStaticsMethod = 'extraDBFields';
|
||||||
} else {
|
} else {
|
||||||
@ -57,9 +64,9 @@ abstract class DataObjectDecorator extends Extension {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If the extension has been manually applied to a subclass, we should ignore that.
|
// If the extension has been manually applied to a subclass, we should ignore that.
|
||||||
if(Object::has_extension(get_parent_class($class), $extension)) return;
|
if(Object::has_extension(get_parent_class($class), $extensionClass)) return;
|
||||||
|
|
||||||
$statics = call_user_func(array($extension, $extraStaticsMethod), $class);
|
$statics = call_user_func(array($extensionClass, $extraStaticsMethod), $class, $extension);
|
||||||
|
|
||||||
if($statics) {
|
if($statics) {
|
||||||
foreach($statics as $name => $newVal) {
|
foreach($statics as $name => $newVal) {
|
||||||
|
Loading…
Reference in New Issue
Block a user