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:
Sam Minnee 2010-03-15 05:07:05 +00:00
parent d084a7053f
commit 2a22e73615
3 changed files with 12 additions and 9 deletions

View File

@ -439,7 +439,7 @@ abstract class Object {
// load statics now for DataObject classes
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')) {
$extensions = Object::uninherited_static($class, 'extensions');
if($extensions) foreach($extensions as $extension) {
if(preg_match('/^([^(]*)/', $extension, $matches)) {
$extensionClass = $matches[1];
DataObjectDecorator::load_extra_statics($class, $extensionClass);
}
DataObjectDecorator::load_extra_statics($class, $extension);
}
}
}

View File

@ -462,7 +462,6 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
$class = get_class($instance);
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

View File

@ -48,8 +48,15 @@ abstract class DataObjectDecorator extends Extension {
if(!empty(self::$extra_statics_loaded[$class][$extension])) return;
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()
if(method_exists($extension, 'extraDBFields')) {
if(method_exists($extensionClass, 'extraDBFields')) {
user_error('DataObjectDecorator::extraDBFields() is deprecated. Please use extraStatics() instead.', E_USER_NOTICE);
$extraStaticsMethod = 'extraDBFields';
} 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(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) {
foreach($statics as $name => $newVal) {