BUGFIX: Tidied up relObject() behaviour on DataLists to restore broken SearchContext functionality.

This commit is contained in:
Sam Minnee 2012-03-30 15:59:47 +13:00
parent c56176c5d5
commit 58433d38ce
2 changed files with 16 additions and 2 deletions

View File

@ -668,6 +668,10 @@ class DataList extends ViewableData implements SS_List, SS_Filterable, SS_Sortab
return singleton($this->dataClass)->$relationName()->forForeignID($ids); return singleton($this->dataClass)->$relationName()->forForeignID($ids);
} }
function dbObject($fieldName) {
return singleton($this->dataClass)->dbObject($fieldName);
}
/** /**
* Add a number of items to the component set. * Add a number of items to the component set.
* *

View File

@ -2404,8 +2404,13 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
// Traverse dot syntax // Traverse dot syntax
$component = $this; $component = $this;
foreach($parts as $relation) { foreach($parts as $relation) {
if($component instanceof SS_List) {
if(method_exists($component,$relation)) $component = $component->$relation();
else $component = $component->relation($relation);
} else {
$component = $component->$relation(); $component = $component->$relation();
} }
}
$object = $component->dbObject($fieldName); $object = $component->dbObject($fieldName);
@ -2436,8 +2441,13 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
// Traverse dot syntax // Traverse dot syntax
$component = $this; $component = $this;
foreach($parts as $relation) { foreach($parts as $relation) {
if($component instanceof SS_List) {
if(method_exists($component,$relation)) $component = $component->$relation();
else $component = $component->relation($relation);
} else {
$component = $component->$relation(); $component = $component->$relation();
} }
}
return $component->$fieldName; return $component->$fieldName;
} else { } else {